Skip to content

Commit

Permalink
Use Cane::RakeTask instead of invoking cane manually
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Sep 14, 2016
1 parent 8450cc8 commit 24e8ca0
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@ ruby_19 = RUBY_VERSION > '1.9'
ruby_mri = !defined?(RUBY_ENGINE) || 'ruby' == RUBY_ENGINE
default_gemfile = ENV['BUNDLE_GEMFILE'] =~ /Gemfile$/

begin
require 'cane/rake_task'
rescue LoadError
warn "warning: cane not available; skipping quality checks."
else
desc %(Check code quality metrics with Cane)
Cane::RakeTask.new(:quality) do |cane|
cane.abc_max = 15
cane.style_measure = 110
cane.max_violations = 0
cane.add_threshold 'coverage/covered_percent', :>=, 98.5
end
end

if ruby_19 && ruby_mri && default_gemfile
task :default => [:enable_coverage, :spec]
task :default => :quality if RUBY_VERSION < '2.2'
task :default => :quality if defined?(Cane)
else
task :default => [:spec]
end
Expand All @@ -18,12 +32,3 @@ RSpec::Core::RakeTask.new(:spec)
task :enable_coverage do
ENV['COVERAGE'] = 'yes'
end

desc %(Check code quality metrics with Cane)
task :quality do
sh 'cane',
'--abc-max=15',
'--style-measure=110',
'--gte=coverage/covered_percent,98.5',
'--max-violations=0'
end

0 comments on commit 24e8ca0

Please sign in to comment.