How to find suspect cut and paste code

PMD comes with a usefull feature called CPD. CPD stands for Cut and Paste Detector. It's a tool that scan a set of files and look for suspect code replicas.

To check the files of a project, simply select "Find Suspect Cut And Paste" on the project context menu. After scanning, a report window will be displayed indicating if duplicate code has been found and where.

CPD can be parameterized by the minimum size of the replica. To specify this parameter, open the workbench preferences dialog and select the PMD->CPD Preferences category. In the "Minimum tile size" entry field, enter the size specified in number of lines.