What tools can I use to find duplicate code that is a good candiate for refactoring?
Update:
Any language, any IDE.
What tools can I use to find duplicate code that is a good candiate for refactoring?
Update:
Any language, any IDE.
Name
comparator, filterator — fast location of common code in large source trees
Synopsis
comparator [-c] [-C] [-d dir] [-h] [-m minsize] [-n] [-N normalization-spec] [-o file] [-s shredsize] [-v] [-w] [-x] path...
filterator [-d dir] [-m minsize]
comparator.py
DESCRIPTIONcomparator is a program for quickly finding common sections in two or more source-code trees. It's named after a now-obsolete astronomical instrument called a blink comparator that was used to find moving objects in starfield photos. These reports tend to be noisy; filterator is a postprocessor for comparator reports that can apply significance filtering. comparator.py is a Python module for interpreting comparator reports; filterator uses it.
A good tool is PMD. It has copy-paste detection (CPD) for Java, JSP, C, C++, Fortran and PHP. For more information: http://pmd.sourceforge.net/cpd.html
Checkstyle can do that for Java, though there where too many false reports for my taste.
See CloneDR, a tool for finding exact and near-miss clones (copy-paste-edit) across large software systems. CloneDR uses a language parser to detect clones according to the language structure,thereby minimizing false positives.
CloneDR works with a wide variety of languages (C, C++, C#, Java, PHP, COBOL, ...).
Sample clone detection reports for various langauges can be seen at the website.
EDIT OCTOBER 2010: ... now handles VisualBasic (VBScript, VB6, VB.net)