🕷 software projects

by ryan davis



code analyzer that reports structural similarities

Flay analyzes code for structural similarities. Differences in literal values, variable, class, method names, whitespace, programming style, braces vs do/end, etc are all ignored. Making this totally rad.

  • Plugin system allows other languages to be flayed.
    • Ships with .rb and .erb. javascript and others will be available separately.
  • Includes FlayTask for Rakefiles.
  • Differences in literal values, variable, class, and method names are ignored.
  • Differences in whitespace, programming style, braces vs do/end, etc are ignored.
  • Works across files.
  • Reports differences at any level of code.
  • Totally rad.
  • Adds a score multiplier to identical nodes.
  • Run verbose to see an N-way diff of the code.

Actual Output

% flay -v ~/Work/svn/ruby/ruby_1_8/lib/cgi.rb
Processing /Users/ryan/Work/svn/ruby/ruby_1_8/lib/cgi.rb...

Matches found in :defn (mass = 184)
  A: /Users/ryan/Work/svn/ruby/ruby_1_8/lib/cgi.rb:1470
  B: /Users/ryan/Work/svn/ruby/ruby_1_8/lib/cgi.rb:1925

A: def checkbox_group(name = "", *values)
B: def radio_group(name = "", *values)
     if name.kind_of?(Hash) then
       values = name["VALUES"]
       name = name["NAME"]
     values.collect do |value|
       if value.kind_of?(String) then
A:       (checkbox(name, value) + value)
B:       (radio_button(name, value) + value)
         if (value[(value.size - 1)] == true) then
A:         (checkbox(name, value[0], true) + value[(value.size - 2)])
B:         (radio_button(name, value[0], true) + value[(value.size - 2)])
A:         (checkbox(name, value[0]) + value[(value.size - 1)])
B:         (radio_button(name, value[0]) + value[(value.size - 1)])

IDENTICAL Matches found in :for (mass*2 = 144)
  A: /Users/ryan/Work/svn/ruby/ruby_1_8/lib/cgi.rb:2160
  B: /Users/ryan/Work/svn/ruby/ruby_1_8/lib/cgi.rb:2217

   for element in ["HTML", "BODY", "P", "DT", "DD", "LI", "OPTION", "THEAD", "TFOOT", "TBODY", "COLGROUP", "TR", "TH", "TD", "HEAD"] do
     methods = (methods + (("          def #{element.downcase}(attributes = {})\n" + nO_element_def(element)) + "          end\n"))

Get The Code

If you just want to use flay, you can install it via RubyGems:
gem install flay
Fork me on GitHub If you want to hack on flay, clone it from GitHub:
git clone git://github.com/seattlerb/flay

Latest Activity