Recently in flay Category

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.

Changes:

1.4.1 / 2010-09-01

  • 2 minor enhancements:

    • Added extra error handling for ERB flay to deal with tons of bad ERB
    • Skip plugin if another version already loaded (eg local vs gem).
  • 1 bug fix:

    • Fixed all tests that were having problems on 1.9 due to unstable hashes
  • http://ruby.sadi.st/

  • http://rubyforge.org/projects/seattlerb

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.

Changes:

1.4.0 / 2009-08-14

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.

Changes:

1.3.0 / 2009-06-23

  • 5 minor enhancements:

    • Added --summary to display flay scores per file.
    • Added --verbose to display processing progress.
    • Protect against syntax errors in bad code and continue flaying.
    • Removed fuzzy matching. Never got it to feel right. Slow. Broken on 1.9
    • Renamed --verbose to --diff.
  • http://ruby.sadi.st/

  • http://rubyforge.org/projects/seattlerb

ParseTree EOL

| | Comments (3)

There seems to be some confusion and/or panic about ParseTree that I'd like to clear up:

ParseTree is dead on ruby 1.9 and there is no plan to make it work.

Because of changes to internals in 1.9, ParseTree simply can not work. I asked for hooks/options to allow us to get to the information but they never arrived.

Specifically if you're using ParseTree to access the AST of a live method/block/proc, you're SOL. If you're just using ParseTree to do static analysis, then you can switch to ruby_parser in about a minute of work and you're good to go.

Here is the plan for my projects:

  • RubyToC-1.0.0.5 = switching to ruby_parser
  • flog-2.1.0 = switching to ruby_parser
  • heckle-1.4.2 = dead, unless we can think of something soon.
  • ruby2ruby-1.2.2 = dropping block/proc support.
  • ruby_parser-2.0.2 = no clue why it has a dependency still, no worries here.
  • ZenHacks-1.0.1 = dropping block/proc support -- not that I support this.

I don't know the status of most of the projects dependent on PT or how they're going to deal with this issue. If you use one of these projects directly or indirectly and that project relies on PT for live method/block/proc, then you're probably going to be stuck on 1.8 for a while:

  • SuperCaller-1.0.0 = unsupported - can drop live method support
  • ambition-0.5.4
  • argible-0.1.1
  • integrity-0.1.9.3
  • merb-action-args-1.0.11
  • nitpick-1.0.2
  • protocol-0.8.1
  • red-4.1.7
  • reek-1.0.0 = probably doesn't need live analysis
  • roodi-1.3.5
  • ruby_diff-0.2
  • rubyjs-0.8.0
  • sake-1.0.15
  • thorero-action-args-0.9.4

There are probably other projects out there dependent on PT that I don't know about. All I've listed here are rubyforge gems that depend on PT in their gemspec.

You can check your gems using this:

gem list | egrep "(ambition|argible|integrity|merb-action-args|nitpick|protocol|red|reek|roodi|ruby_diff|rubyjs|sake|thorero-action-args)"

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.

Changes:

1.2.1 / 2009-03-16

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.

Changes:

1.2.0 / 2009-03-09

  • 2 major enhancements:

    • Added flay_task.rb
    • Added plugin system (any flay_(c,java,js,etc).rb files).
  • 4 minor enhancements:

    • Added expanddirsto_files and made dirs valid arguments.
    • Added flay_erb.rb plugin.
    • Added optparse option processing.
    • Refactored to make using w/in rake and other CI systems clean and easy.
  • http://ruby.sadi.st/

  • http://rubyforge.org/projects/seattlerb

flayjs... flayc...

| | Comments (2)

70 and 61 lines of code respectively...

anyone know of a java parser in ruby?

Flay analyzes ruby 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.

Changes:

1.1.0 / 2009-01-20

  • 8 minor enhancement:

    • Added -v verbose mode to print out N-way diff of the detected code.
    • Added identical node scoring and reporting.
    • Added the start of copy/paste+edit detection, not even close yet
    • Added more tests.
    • Added rcov tasks
    • Added the start of copy/paste+edit detection
    • Clarified output a bit
    • Refactored process_sexps to make doing other languages/systems easier.
  • http://ruby.sadi.st/

  • http://rubyforge.org/projects/seattlerb

I said the following in my previous post about flay:

"Soon I will write up why flay kicks towelee [sic], PMD, and everyone else's tool in the ass... But I think the above is a damn good start."

There are going to be two classes of tools for this type of work: string-based tools and AST-based tools.

Towelie

Towelie is Giles' entry into the fray of ruby developer tools. Towelie is an AST-based tool that uses ParseTree to detect duplicate code at the method level.

There aren't nearly as many available to us rubyists, so it is worth a peek... But, after closer inspection, I just can't compare the two. Yes, towelie attempts to detect duplicated (but not similar) code, but that is where the similarities end, so the comparison doesn't seem fair.

Consider it an exercise for the reader.

PMD's CPD, Simian, Same, etc.

On the CPD page it says that the current version "was rewritten by Steve Hawkins to use the Karp-Rabin string matching algorithm". In other words, it is a string-based tool. This family of tools have completely different objectives than flay. They're normalizing whitespace,stripping comments, and looking for duplicate code. That's great... it actually finds lots and lots of good stuff and I used to use same when starting with new clients.

But... (there is always a but...)

These tools would (could!) NEVER point this out:

Matches found in :defn (mass = 32)
  A: ../../drawr/dev/lib/drawr.rb:38
  B: ../../png/dev/lib/png.rb:181

A: def write(file)
B: def save(path)
A:   File.open(file, "wb") { |f| f.write(to_s) }
B:   File.open(path, "wb") { |f| f.write(to_blob) }
   end

especially considering the code is actually written like this:

def write(file); File.open(file, 'wb') { |f| f.write to_s }; end

vs:

def save(path)
  File.open path, 'wb' do |f|
    f.write to\_blob
  end
end

This is something that a duplicate code string-based scanner just can't do. Even the simplest change like {} vs do/end or changing your line wrapping on long conditionals will be missed... lost... ignored.

So, flay has the ability to go beyond simple copy/pasted code and detect real candidates for refactoring. That is something that the java folks don't seem to have (yet) for some reason. Certainly the foundation set by PMD means it is available, but it isn't there yet.

Flay is blowing my mind

| | Comments (0)

No, really. Flay is blowing my mind. It is just getting cooler and cooler. The next version of flay is going to have a verbose mode that will try to show an N-way diff:

Matches found in :when (mass = 84)
  A: unit/itemconfig.rb:182
  B: unit/itemconfig.rb:192
  C: unit/itemconfig.rb:207

A: when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join("|")})$/ then
B: when /^(#{__item_listval_optkeys(tagid(tagOrId)).join("|")})$/ then
C: when /^(#{__item_strval_optkeys(tagid(tagOrId)).join("|")})$/ then
A:   num_or_str(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
B:   simplelist(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
C:   _fromUTF8(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))

And Patrick Ritchie recently submitted additional similarity reporting that I'm going to work on folding in soon. His version allows extra fuzzier matching of copy-pasted code that has been edited!

Soon I will write up why flay kicks towelee, PMD, and everyone else's tool in the ass... But I think the above is a damn good start.

About this Archive

This page is a archive of recent entries in the flay category.

RubyInline is the previous category.

flog is the next category.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.32-en