duplicated expressions again

A couple of weeks ago I wrote about my search for tools for detection of duplicated expressions. In the interim, I’m pleased to report that Neil at Integility has fixed the Simian plugin for Eclipse. Thanks Neil!

Also Hugh Sasse wrote and pointed me at the ruby quiz he submitted to solve a similar problem: to write a Ruby program that will analyse a text for duplicate strings and then create another Ruby program that will output that original text. Not quite what I was looking for, but some of the solutions to Hugh’s challenge are neat. Thanks for the link, Hugh.

I think, though, that I’m looking more for something that understands (ie. parses) the source code, so that it can make reasonable decisions about what constitutes an expression and what constitutes duplication. And wouldn’t it be great if it actually performed ExtractMethod on the duplicates it found…!

detection of duplicated expressions

This week I’ve been looking at tools for detecting code duplication – specifically Simian and CPD. I didn’t try CPD in the end, because although it supports Ruby, CPD is bundled with PMD, which doesn’t. I did try Simian, and was impressed by the results. (I’m sure I would have been even more impressed if the alleged Eclipse plugin was still available.)

But I’m still searching for the tool I really wanted: something that can detect duplicated expressions. For example, here’s part of a class from William Wake’s Refactoring Workbook (ch14):