Flay is terribly useful, but has terribly usability …
If the repo was not such a mess I’d make PRs to fix it, but tests are not even runnable and PRs to make the Readme readabe got rejected … so I’m not going to bother … a small excerpt from Samson
More config options can be found on it’s homepage
Just wanted to share this useful rake task which found a bunch of duplication and already prevented me from adding new duplication twiceImage may be NSFW.
Clik here to view.
desc "Analyze for code duplication (large, identical syntax trees) with fuzzy matching." task :flay do require 'flay' # do not require in production # FIXME: flay has a --mass option, but it ignores everything Flay.prepend(Module.new do def analyze(*) data = super data.select! { |i| i.mass > 50 } self.total = data.sum(&:mass) data end end) files = Dir["{config,lib,app/**/*.{rb,erb}"] files -= [ # Things you want to ignore ] flay = Flay.run(files) abort "Code duplication found" if flay.report.any? end
Tagged: Ruby, TDD, Test Image may be NSFW.
Clik here to view.

Clik here to view.
