Sha256: 78e928b539b5c7dc46aa12c3a2a2e729d6a4faceebd5207948bfce4aace12e0e
Contents?: true
Size: 647 Bytes
Versions: 8
Compression:
Stored size: 647 Bytes
Contents
begin require 'flog' desc 'Analyze for code complexity' task :flog do flog = Flog.new(continue: true) flog.flog(*FileList['lib/**/*.rb']) threshold = 10 bad_methods = flog.totals.select do |name, score| !(/##{flog.no_method}$/ =~ name) && score > threshold end bad_methods.sort { |a, b| a[1] <=> b[1] }.reverse.each do |name, score| printf "%8.1f: %s\n", score, name end unless bad_methods.empty? $stderr.puts "#{bad_methods.size} methods "\ "have a complexity > #{threshold}" end end rescue LoadError task :flog do $stderr.puts 'Flog is disabled' end end
Version data entries
8 entries across 8 versions & 1 rubygems