Skip to content

Instantly share code, notes, and snippets.

@yasuhito
Created March 30, 2010 07:30
Show Gist options
  • Save yasuhito/348873 to your computer and use it in GitHub Desktop.
Save yasuhito/348873 to your computer and use it in GitHub Desktop.
flog.rake
require "rake/tasklib"
require "flog"
desc "Analyze for code complexity"
task :flog do
flog = Flog.new
flog.flog [ "lib" ]
threshold = 10
bad_methods = flog.totals.select do | name, score |
name != "main#none" && 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment