PHPCPD github

這是一個用來檢測PHP專案中是否有相同程式碼的工具

要用PEAR安裝

1#將pear改成會自動搜尋相關的套件
2pear config-set auto_discover 1
3pear install pear.phpunit.de/phpcpd

使用方法

1phpcpd project/

顯示結果(有兩個檔案5-31行是重複的)

1phpcpd 1.4.0 by Sebastian Bergmann.
2 
3Found 1 exact clones with 26 duplicated lines in 2 files:
4 
5  - /usr/local/www/apache22/data/zend/index.php:5-31
6    /usr/local/www/apache22/data/zend/public/index.php:5-31
7 
820.80% duplicated lines out of 125 total lines of code.
9 
10Time: 0 seconds, Memory: 1.50Mb
Categories: PHP