class Fudge::Tasks::Flay

Allow use of Flay complexity analyser

task :flay

runs flay with max score of 0

task :flay, :exclude => 'subpath/'

excludes files matching :exclude from run

task :flay, :max => 20

sets max score to 20

Any and all options can be defined

Private Instance Methods

check_for() click to toggle source
# File lib/fudge/tasks/flay.rb, line 33
def check_for
  [check_regex, method(:flay_checker)]
end
check_regex() click to toggle source
# File lib/fudge/tasks/flay.rb, line 37
def check_regex
  /Total score \(lower is better\) = (?<score>\d+)/
end
cmd(options={}) click to toggle source
# File lib/fudge/tasks/flay.rb, line 24
def cmd(options={})
  bundle_cmd(flay_ruby_files, options)
end
flay_checker(matches) click to toggle source
# File lib/fudge/tasks/flay.rb, line 41
def flay_checker(matches)
  score = matches[:score].to_i
  if score > max_score
    "Duplication Score Higher Than #{max_score}"
  else
    true
  end
end
flay_ruby_files() click to toggle source
# File lib/fudge/tasks/flay.rb, line 28
def flay_ruby_files
  finder = FileFinder.new(options)
  finder.generate_command("flay", tty_options)
end
max_score() click to toggle source
# File lib/fudge/tasks/flay.rb, line 50
def max_score
  options.fetch(:max, 0)
end
tty_options() click to toggle source
# File lib/fudge/tasks/flay.rb, line 54
def tty_options
  opts = []
  opts << "--diff"
  opts
end