PHPCPDPHP 复制/粘贴检测器
PHPCPD 是 PHP 代码的复制/粘贴检测器 (CPD)。
这个工具作为 PHP 存档(PHAR)分发:
$ wget https://phar.phpunit.de/phpcpd.phar
$ php phpcpd.phar --version
推荐使用 Phive 作为管理项目的工具依赖:
$ phive install phpcpd
$ ./tools/phpcpd --version
不推荐使用 Composer 下载并安装此工具。
用例
$ php phpcpd.phar --fuzzy wordpress-5.5
phpcpd 6.0.0 by Sebastian Bergmann.
Found 121 clones with 8137 duplicated lines in 69 files:
- /home/sb/wordpress-5.5/wp-includes/sodium_compat/src/Core/Curve25519/H.php:19-1466 (1447 lines)
/home/sb/wordpress-5.5/wp-includes/sodium_compat/src/Core32/Curve25519/H.php:19-1466
.
.
.
- /home/sb/wordpress-5.5/wp-includes/sodium_compat/src/Core32/Curve25519.php:879-889 (10 lines)
/home/sb/wordpress-5.5/wp-includes/sodium_compat/src/Core32/Curve25519.php:1072-1082
1.82% duplicated lines out of 446676 total lines of code.
Average size of duplication is 67 lines, largest clone has 1447 of lines
Time: 00:02.980, Memory: 318.00 MB
评论