Reputation: 38714
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
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
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
Reputation: 6956
PMD includes a copy-paste detector, it "works with Java, JSP, C, C++, Fortran and PHP code".
Upvotes: 1