lib/quality/rake/task.rb in quality-0.2.5 vs lib/quality/rake/task.rb in quality-0.2.6
- old
+ new
@@ -87,24 +87,22 @@
emacs_format ||= options[:emacs_format]
violations = 0
out = ""
found_output = false
- if defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
+ if defined?(RUBY_ENGINE) && (RUBY_ENGINE == 'jruby')
full_cmd = "jruby -S #{cmd}"
elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
full_cmd = "#{cmd}.bat"
else
full_cmd = cmd
end
-
if !args.nil?
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"
@@ -146,23 +144,25 @@
def quality_cane
if ! File.exist?(".cane")
File.open(".cane", "w") {|f| f.write("-f **/*.rb")}
end
ratchet_quality_cmd("cane",
+ gives_error_code_on_violations: true,
emacs_format: true) { |line|
if line =~ /\(([0-9]*)\):$/
$1.to_i
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: args,
emacs_format: true) { |line|
if line =~ /^ .* (.*)$/
@@ -179,10 +179,10 @@
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]*$/
+ elsif line =~ /^ *([0-9.]*): (.*) .*.rb:[0-9]*$/
score = $1.to_i
if score > threshold
1
else
0