lib/quality/rake/task.rb in quality-0.2.2 vs lib/quality/rake/task.rb in quality-0.2.3

- old
+ new

@@ -1,9 +1,10 @@ #!/usr/bin/env ruby require 'rake' require 'rake/tasklib' +require 'rbconfig' module Quality # # Defines a task library for running quality's various tools @@ -82,17 +83,24 @@ &process_output_line) args ||= options[:args] emacs_format ||= options[:emacs_format] + + violations = 0 out = "" found_output = false - full_cmd = cmd + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + ext='.bat' + end + full_cmd = "#{cmd}#{ext}" if !args.nil? - full_cmd = "#{cmd} #{args}" + full_cmd = "#{full_cmd} #{args}" end + + IO.popen(full_cmd) do |f| while line = f.gets if emacs_format if line =~ /^ *(\S*.rb:[0-9]*) *(.*)/ out << $1 << ": " << $2 << "\n" @@ -140,14 +148,18 @@ else 0 end } end - + def ruby_files + Dir.glob('*.rb').concat(Dir.glob(File.join('{lib,test}', '**', '*.rb'))).join(' ') + end def quality_reek + + args = "--line-number #{ruby_files}" ratchet_quality_cmd("reek", - args: "--line-number *.rb lib/*.rb 2>/dev/null", + args: args, emacs_format: true) { |line| if line =~ /^ .* (.*)$/ 1 else 0 @@ -156,11 +168,11 @@ end def quality_flog threshold = 50 ratchet_quality_cmd("flog", - args: "--all --continue --methods-only . 2>/dev/null", + args: "--all --continue --methods-only #{ruby_files}", emacs_format: true) { |line| if line =~ /^ *([0-9.]*): flog total$/ 0 #$1.to_i elsif line =~ /^ *([0-9.]*): (.*) .\/.*.rb:[0-9]*$/ @@ -176,11 +188,11 @@ } end def quality_flay ratchet_quality_cmd("flay", - args: "-m 75 -t 99999 . 2>/dev/null", + args: "-m 75 -t 99999 #{ruby_files}", emacs_format: true) { |line| if line =~ /^[0-9]*\).* \(mass = ([0-9]*)\)$/ $1.to_i else 0 @@ -188,10 +200,10 @@ } end def quality_rubocop ratchet_quality_cmd("rubocop", - args: "--format emacs 2>&1") { |line| + args: "--format emacs #{ruby_files}") { |line| if line =~ /^.* files inspected, (.*) offences detected$/ $1.to_i else 0 end