lib/quality/quality_checker.rb in quality-13.0.0 vs lib/quality/quality_checker.rb in quality-14.0.0
- old
+ new
@@ -1,10 +1,9 @@
require_relative 'command_output_processor'
-require_relative 'process_runner'
+require_relative 'process'
require_relative 'ruby_spawn'
-# XXX: Should add *.gemspec to glob
module Quality
# Runs a quality-checking, command, checks it agaist the existing
# number of violations for that command, and decreases that number
# if possible, or outputs data if the number of violations increased.
class QualityChecker
@@ -12,21 +11,21 @@
count_file: File,
count_io: IO,
command_output_processor_class:
Quality::CommandOutputProcessor,
count_dir: Dir,
- process_runner_class: ProcessRunner)
+ process_class: Process)
@count_file = count_file
@count_io = count_io
@command_output_processor_class = command_output_processor_class
@count_dir = count_dir
@cmd = cmd
@command_options = command_options
@verbose = verbose
@count_dir.mkdir(output_dir) unless @count_file.exists?(output_dir)
@filename = File.join(output_dir, "#{cmd}_high_water_mark")
- @process_runner_class = process_runner_class
+ @process_class = process_class
end
def execute(&count_violations_on_line)
processor, exit_status = process_command(&count_violations_on_line)
@violations = processor.violations
@@ -42,24 +41,24 @@
exit_status = run_command(processor, &count_violations_on_line)
[processor, exit_status]
end
def run_command(processor, &count_violations_on_line)
- runner = @process_runner_class.new(full_cmd)
+ runner = @process_class.new(full_cmd)
puts full_cmd if @verbose
runner.run do |file|
processor.file = file
@command_output = processor.process(&count_violations_on_line)
end
end
def check_exit_status(exit_status)
- return if @command_options[:gives_error_code_on_violations]
+ return if @command_options[:gives_error_code_on_violations] ||
+ @command_options[:gives_error_code_on_no_relevant_code]
fail("Error detected running #{full_cmd}. " \
- "Exit status is #{exit_status}, " \
- "output is [#{out}]") if exit_status != 0
+ "Exit status is #{exit_status}") if exit_status != 0
end
def existing_violations
if @count_file.exist?(@filename)
@count_io.read(@filename).to_i