Sha256: 68dae7bb12ec3246542e83c44923ded3ccd89de67accdd71117c44401f43a911

Contents?: true

Size: 647 Bytes

Versions: 35

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

35 entries across 35 versions & 2 rubygems

Version Path
trema-0.10.1 tasks/flog.rake
trema-0.10.0 tasks/flog.rake
phut-0.7.7 tasks/flog.rake
phut-0.7.6 tasks/flog.rake
trema-0.9.0 tasks/flog.rake
phut-0.7.5 tasks/flog.rake
trema-0.8.4 tasks/flog.rake
phut-0.7.4 tasks/flog.rake
trema-0.8.3 tasks/flog.rake
phut-0.7.3 tasks/flog.rake
trema-0.8.2 tasks/flog.rake
phut-0.7.2 tasks/flog.rake
trema-0.8.1 tasks/flog.rake
phut-0.7.1 tasks/flog.rake
trema-0.8.0 tasks/flog.rake
phut-0.7.0 tasks/flog.rake
phut-0.6.11 tasks/flog.rake
trema-0.7.1 tasks/flog.rake
trema-0.7.0 tasks/flog.rake
phut-0.6.10 tasks/flog.rake