lib/quality/rake/task.rb in quality-1.3.1 vs lib/quality/rake/task.rb in quality-2.0.0
- old
+ new
@@ -48,12 +48,12 @@
# Defaults to []
attr_accessor :skip_tools
# Array of directory names which contain ruby files to analyze.
#
- # Defaults to %w(lib test spec feature), which translates to *.rb in
- # the base directory, as well as lib, test, and feature.
+ # Defaults to %w(app lib test spec feature), which translates to *.rb in
+ # the base directory, as well as those directories.
attr_writer :ruby_dirs
# Relative path to output directory where *_high_water_mark
# files will be read/written
#
@@ -64,11 +64,11 @@
def initialize(args = {})
parse_args(args)
@skip_tools = []
- @output_dir = '.'
+ @output_dir = 'metrics'
yield self if block_given?
define
end
@@ -141,16 +141,14 @@
def run_quality_with_tool(tool)
installed = @gem_spec.find_all_by_name(tool).any?
suppressed = @skip_tools.include? tool
- if !installed
- puts "#{tool} not installed"
- elsif suppressed
- puts "Suppressing use of #{tool}"
- else
+ if installed && !suppressed
method("quality_#{tool}".to_sym).call
+ elsif !installed
+ puts "#{tool} not installed"
end
end
def run_ratchet
@globber.glob("#{@output_dir}/*_high_water_mark").each do |filename|
@@ -161,40 +159,34 @@
def run_ratchet_on_file(filename)
puts "Processing #{filename}"
existing_violations = count_existing_violations(filename)
new_violations = [0, existing_violations - 1].max
write_violations(filename, new_violations)
- tighten_standard(filename) if new_violations != existing_violations
end
def write_violations(filename, new_violations)
@count_file.open(filename, 'w') do |file|
- file.write(new_violations.to_s)
+ file.write(new_violations.to_s + "\n")
end
end
def count_existing_violations(filename)
existing_violations = @count_io.read(filename).to_i
fail("Problem with file #{filename}") if existing_violations < 0
existing_violations
end
- def tighten_standard(filename)
- @cmd_runner
- .system("git commit -m 'tighten quality standard' #{filename}")
- end
-
def ratchet_quality_cmd(cmd,
command_options,
&count_violations_on_line)
quality_checker = @quality_checker_class.new(cmd,
command_options,
@output_dir)
quality_checker.execute(&count_violations_on_line)
end
def ruby_dirs
- @ruby_dirs ||= %w(lib test spec feature)
+ @ruby_dirs ||= %w(app lib test spec feature)
end
def ruby_files_glob
File.join("{#{ruby_dirs.join(',')}}",
'**', '*.rb')