sebastianbergmann/phpcpd — pull request #70 by alexshadow007 (2013-07-11 20:06:13+00:00)
Title: Merge code duplicates by equivalent code fragment

I use phpcpd with Jenkins plugin DRY.

After build job, i got this result:
```
phpcpd 1.4.1-21-g105262a by Sebastian Bergmann.
Found 120 exact clones with 11743 duplicated lines in 151 files:
...
- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:294-317
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:376-399

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:316-344
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:398-426

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:294-317
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:465-488

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:316-344
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:487-515

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:294-344
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:559-609

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:227-238
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:712-723
...

2.59% duplicated lines out of 453944 total lines of code.

Time: 20 seconds, Memory: 335.25Mb
[DRY] Collecting duplicate code analysis files...
[DRY] Finding all files that match the pattern **/cpd.xml
[DRY] Parsing 1 files in /opt/jenkins/.jenkins/jobs/pmd-test/workspace
[DRY] Successfully parsed file /opt/jenkins/.jenkins/jobs/pmd-test/workspace/cpd.xml of module with 237 warnings.
```

But DRY report includes only 8 files.

![phpcpd_without_fix](https://f.cloud.github.com/assets/647552/784387/805e2a2e-ea63-11e2-90f5-b5c1dbecdf34.png)

For fix this, i merge code duplicates by code fragment.

Job result after fix:
```
phpcpd 1.4.1-24-gd4194a0 by Sebastian Bergmann.
Found 117 exact clones with 11743 duplicated lines in 151 files:
...
- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:294-317
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:376-399
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:465-488

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:316-344
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:398-426
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:487-515

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:294-344
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:559-609

- /opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:227-238
/opt/jenkins/.jenkins/jobs/pmd-test/workspace/tests/unit/AccessoryFetcherTest.php:712-723
...
2.59% duplicated lines out of 453944 total lines of code.

Time: 20 seconds, Memory: 336.25Mb
[DRY] Collecting duplicate code analysis files...
[DRY] Finding all files that match the pattern **/cpd.xml
[DRY] Parsing 1 files in /opt/jenkins/.jenkins/jobs/pmd-test/workspace
[DRY] Successfully parsed file /opt/jenkins/.jenkins/jobs/pmd-test/workspace/cpd.xml of module with 237 warnings.

```

Now DRY show all 10 files.

![phpcpd_with_fix](https://f.cloud.github.com/assets/647552/784395/a384e790-ea63-11e2-8776-8f2ebfa2bc15.png)

I think that this kind of output is more informative.