Skip to content

Instantly share code, notes, and snippets.

@bnadlerjr
Created April 30, 2013 00:38
Show Gist options
  • Save bnadlerjr/5485886 to your computer and use it in GitHub Desktop.
Save bnadlerjr/5485886 to your computer and use it in GitHub Desktop.
unless 'production' == ENV['RACK_ENV']
require "flay_task"
FlayTask.new do |t|
t.dirs = %w[lib]
end
require "flog"
desc 'Analyze code using ABC metric'
task :flog do
flog = Flog.new
flog.flog ['lib']
threshold = 50
bad_methods = flog.totals.select do |name, score|
score > threshold
end
bad_methods.sort do |a, b|
a[1] <=> b[1]
end.each do |name, score|
puts "%8.1f: %s" % [score, name]
end
unless bad_methods.empty?
raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment