lib/quality/quality_checker.rb in quality-1.2.0 vs lib/quality/quality_checker.rb in quality-1.3.0
- old
+ new
@@ -1,6 +1,7 @@
require_relative 'command_output_processor'
+require 'English'
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.
@@ -28,26 +29,27 @@
def process_command(&count_violations_on_line)
processor = @command_output_processor_class.new
processor.emacs_format = @command_options[:emacs_format]
exit_status = run_command(processor, &count_violations_on_line)
- [processor, $?.exitstatus]
+ [processor, exit_status]
end
def run_command(processor, &count_violations_on_line)
@popener.popen(full_cmd) do |file|
processor.file = file
@command_output = processor.process!(&count_violations_on_line)
end
+ $CHILD_STATUS.exitstatus
end
def check_exit_status(exit_status)
- unless @command_options[:gives_error_code_on_violations]
- if exit_status != 0
- fail("Error detected running #{full_cmd}. " +
- "Exit status is #{exit_status}, output is [#{out}]")
- end
+ return if @command_options[:gives_error_code_on_violations]
+
+ if exit_status != 0
+ fail("Error detected running #{full_cmd}. " \
+ "Exit status is #{exit_status}, output is [#{out}]")
end
end
def existing_violations
if @count_file.exist?(@filename)
@@ -59,11 +61,11 @@
def ratchet_violations
existing = existing_violations
report_violations(existing)
if @violations > existing
- fail("Output from #{@cmd}\n\n#{@command_output}\n\n" +
- "Reduce total number of #{@cmd} violations " +
+ fail("Output from #{@cmd}\n\n#{@command_output}\n\n" \
+ "Reduce total number of #{@cmd} violations " \
"to #{existing} or below!")
elsif @violations < existing
puts 'Ratcheting quality up...'
write_violations(@violations)
end