Are there any tools available that can scan multiple .php files and report back duplicated lines/chunks of code?
It doesn't have to be really smart but basically give me a starting point for manual scans to improve the codebase of some of my apps.
Are there any tools available that can scan multiple .php files and report back duplicated lines/chunks of code?
It doesn't have to be really smart but basically give me a starting point for manual scans to improve the codebase of some of my apps.
"Duplicated code is the most pervasive and pungent smell in software." - Martin Fowler
See SD CloneDR, a tool for finding duplicated code across large systems. It finds both exact copies, and near-miss clones (cloned code that has been edited). The CloneDR is driven by language syntax, not text, so it will find clones if the text has been reformatted or variable names changed. Its actually really smart.
You can see a number of CloneDR reports for various languages at the site. For PHP, there's a CloneDR run on the popular web framework Joomla.
Depending on your specific needs you could use phpcpd or CPD. The former will probably be less accurate then the latter, but just test them and see which you like.
BTW They could also be used with CI (Continuous Integration) packages like Hudson or phpUnderControl.