Created
March 30, 2010 07:30
-
-
Save yasuhito/348873 to your computer and use it in GitHub Desktop.
flog.rake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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