JoelFan
JoelFan

Reputation: 38714

copy-and-paste static analysis tool?

Is there any static analysis tool that can process an entire codebase and detect where copy-and-paste has been used (i.e. blocks of duplicated or extremely similar code) so that it can be considered for refactoring?

Upvotes: 2

Views: 1213

Answers (3)

Ira Baxter
Ira Baxter

Reputation: 95400

See our CloneDR tool for finding exact and near-miss clones.

CloneDR uses the structure of the target language (a full, precise language parser) to find clones, and consequently is able to find such clones in spite of formatting, whitespace changes, etc. It will also find consistent renaming of identifiers.

It handles many languages, including Java, C#, VB.net, Python, PHP, JavaScript, C++, PL/SQL, COBOL, Fortran,... The website has sample reports for most of these.

Upvotes: 1

Austen Holmes
Austen Holmes

Reputation: 1939

For java, there's a tool called pmd and it has a copy/paste detector. http://pmd.sourceforge.net/cpd.html

Upvotes: 2

Paul Butcher
Paul Butcher

Reputation: 6956

PMD includes a copy-paste detector, it "works with Java, JSP, C, C++, Fortran and PHP code".

Upvotes: 1

Related Questions