views:

216

answers:

4

Hello!

Are there tools out there which could automatically find copy-and-paste code among a set of files?

I was thinking of writing a script for this, which would just search for equal strings, but such script would find mostly irrelevant equalities. (Such as private final static ...).

+4  A: 

Yes, try the Copy Paste Detector.

msalib
Great! Thank you a lot!
java.is.for.desktop
Thanks for this one. Just one question I could not solve: How do I exclude certain .cpp files?
Derick
+1  A: 

The CloneDR is a tool for finding exact and near-miss blocks of code constructed by copy and paste activities. It can handle systems of millions of lines of code.

It uses precise langauge grammars to pick out language structures (identifiers, expressions, statements, blocks, functions, classes, packages, ...) that have been copied, and to determine the points of variation across the sets of clones (any of those structures can be parameters!)

CloneDR operates on a wide variety of languages (C, C++, C#, Java, PHP, COBOL, Python, Ada, Fortran, ...).

The website has a number of sample clone detection reports from a variety of those languages.

EDIT OCT 2010: EGL, and Visual Basic (VBScript, VB6, VB.net) added.

Ira Baxter
+2  A: 

CloneDigger for Python and Java.

Heikki Toivonen