lib/quality/rake/task.rb in quality-0.0.3 vs lib/quality/rake/task.rb in quality-0.1.0

- old
+ new

@@ -69,13 +69,14 @@ def run_task quality_cane quality_reek quality_flog quality_flay + quality_rubocop end - def quality_quality_cmd(cmd, + def ratchet_quality_cmd(cmd, args: nil, emacs_format: false, &process_output_line) violations = 0 out = "" @@ -124,22 +125,22 @@ def quality_cane if ! File.exist?(".cane") File.open(".cane", "w") {|f| f.write("-f *.rb lib/*.rb test/*.rb")} end - quality_quality_cmd("cane", + ratchet_quality_cmd("cane", emacs_format: true) { |line| if line =~ /\(([0-9]*)\):$/ $1.to_i else 0 end } end def quality_reek - quality_quality_cmd("reek", + ratchet_quality_cmd("reek", args: "--line-number *.rb lib/*.rb 2>/dev/null", emacs_format: true) { |line| if line =~ /^ .* (.*)$/ 1 else @@ -148,11 +149,11 @@ } end def quality_flog threshold = 50 - quality_quality_cmd("flog", + ratchet_quality_cmd("flog", args: "--all --continue --methods-only . 2>/dev/null", emacs_format: true) { |line| if line =~ /^ *([0-9.]*): flog total$/ 0 #$1.to_i @@ -168,18 +169,29 @@ end } end def quality_flay - quality_quality_cmd("flay", + ratchet_quality_cmd("flay", args: "-t 99999 . 2>/dev/null", emacs_format: true) { |line| if line =~ /^[0-9]*\).* \(mass = ([0-9]*)\)$/ $1.to_i else 0 end } + end + + def quality_rubocop + ratchet_quality_cmd("rubocop", + args: "--format emacs 2>&1") { |line| + if line =~ /^.* files inspected, (.*) offences detected$/ + $1.to_i + else + 0 + end + } end def quality Dir.glob("*_high_water_mark").each { |filename| puts "Processing #{filename}"