tags:

views:

72

answers:

2

I don't want tools for actually performing refactorings, but tools for finding and suggesting potential refactorings. Particularly tools for identifying blocks of code that are similar and could be merged into a utility functions.

The background here is that I've been asked to investigate reducing the code size of an embedded C system. This task seems to mostly break down into removing code that isn't needed (dead code) and merging code that is duplicated. The various lint like tools will find the dead code. But I still need a way of finding the duplicated code.

+1  A: 

I'd suggest taking a look at PMD's Copy Paste Detector. While it defaults to Java code, it also supports c++, php, and ruby.

PMD does this on a lexical basis, and has a few options to ignore constants within code. Better code duplicate detectors build up an AST, and compare similar trees. The AST approach is better, as formatting and variable names don't effect the results.

brianegge
A: 

PMD has already been mentioned. ACNP software has one that's commercial (but pretty cheap).

Jerry Coffin