views:

373

answers:

5

What tools can I use to find duplicate code that is a good candiate for refactoring?

Update:

Any language, any IDE.

+2  A: 

This would probably depend on the IDE or language you're using, but the most common tool I've heard of is called Simian.

Brandon
+1  A: 

Comparator

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
DESCRIPTION

comparator 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.

gnibbler
+5  A: 

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

p3t0r
+1  A: 

Checkstyle can do that for Java, though there where too many false reports for my taste.

starblue
A: 

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)

Ira Baxter