Sha256: 795eeaf8ce3dc3758469e8acb257304d485e4098e27fcb26501daeb61df10720

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

unless 'production' == ENV['RACK_ENV']
  require 'flay'
  desc "Analyze code for structural similarities"
  task :flay do
    flay = Flay.new
    files = FileList["app.rb", "app/**/*.rb"]
    flay.process(*files)
    threshold = 200

    if flay.total > threshold
      puts flay.report
      raise "Flay total too high! #{flay.total} > #{threshold}"
    end
  end

  require "flog"
  desc 'Analyze code complexity'
  task :flog do
    flog = Flog.new
    flog.flog FileList["app.rb", "app/**/*.rb"]
    threshold = 50

    bad_methods = flog.totals.select do |name, score|
      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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hoboken-0.0.1 lib/hoboken/templates/metrics.rake.tt
hoboken-0.0.1.beta3 lib/hoboken/templates/metrics.rake.tt
hoboken-0.0.1.beta2 lib/hoboken/templates/metrics.rake.tt
hoboken-0.0.1.beta lib/hoboken/templates/metrics.rake.tt