8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/the_metric_system/units_of_measure/flog_units.rb', line 8
def self.report_to_standards_body(options={})
reasonable_defaults.merge!(options)
require 'flog'
flog = Flog.new :methods => true
flog.flog options[:directories]
threshold = options[:threshold]
bad_methods = flog.totals.select { |name, score| score > threshold }
bad_methods.sort { |a,b| a[1] <=> b[1] }.each do |name, score|
puts "%8.1f: %s" % [score, name]
end
raise "Flog found #{bad_methods.size} methods with a complexity > #{options[:threshold]}" unless bad_methods.empty?
end
|