Commit 2b496d7
Changed files (3)
lib
spandx
cli
commands
core
lib/spandx/cli/commands/scan.rb
@@ -16,18 +16,13 @@ module Spandx
def execute(output: $stdout)
with_printer(output) do |printer|
each_dependency do |dependency|
- printer.print_line(enhance(dependency), output)
+ printer.print_line(Plugin.enhance(dependency), output)
end
end
end
private
- def thread_count
- count = @options[:threads].to_i
- count.positive? ? count : 1
- end
-
def each_file
PathTraversal
.new(scan_path, recursive: @options[:recursive])
@@ -35,11 +30,9 @@ module Spandx
end
def each_dependency
- with_thread_pool(size: thread_count) do |thread|
- each_file do |file|
- Parser.parse(file).each do |dependency|
- thread.run { yield dependency }
- end
+ each_file do |file|
+ Parser.parse(file).each do |dependency|
+ yield dependency
end
end
end
@@ -48,12 +41,6 @@ module Spandx
Array(output).map(&:to_s)
end
- def enhance(dependency)
- Plugin.all.inject(dependency) do |memo, plugin|
- plugin.enhance(memo)
- end
- end
-
def with_printer(output)
printer = ::Spandx::Cli::Printer.for(@options[:format])
printer.print_header(output)
@@ -61,12 +48,6 @@ module Spandx
ensure
printer.print_footer(output)
end
-
- def with_thread_pool(size:)
- ThreadPool.open(size: size) do |pool|
- yield pool
- end
- end
end
end
end
lib/spandx/core/plugin.rb
@@ -9,6 +9,12 @@ module Spandx
class << self
include Registerable
+
+ def enhance(dependency)
+ Plugin.all.inject(dependency) do |memo, plugin|
+ plugin.enhance(memo)
+ end
+ end
end
end
end
lib/spandx/core/thread_pool.rb
@@ -3,7 +3,7 @@
module Spandx
module Core
class ThreadPool
- def initialize(size: Etc.nprocessors)
+ def initialize(size: 1)
@size = size
@queue = Queue.new
@pool = size.times.map { start_worker_thread(@queue) }