Do tools exist which automatically find copy-and-p

2020-02-21 08:00发布

问题:


Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 3 years ago.

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

回答1:

Yes, try the Copy Paste Detector.



回答2:

Our 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 language 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, EGL and visual basic (VBScript, VB6, VB.net).

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

This product is available for evaluation on http://www.semanticdesigns.com. Other open source alternatives are Simian and PMD CPD



回答3:

http://patterninsight.com/products/cp-miner.php
Related paper - http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.123.113



回答4:

CloneDigger for Python and Java.