Linux command
phpcpd 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Find duplicate code
phpcpd [src/]
Set minimum lines
phpcpd --min-lines [10] [src/]
Set minimum tokens
phpcpd --min-tokens [50] [src/]
Exclude directory
phpcpd --exclude [vendor] [src/]
Output to file
phpcpd --log-pmd [report.xml] [src/]
Check multiple directories
phpcpd [src/] [lib/]
Fuzzy matching
phpcpd --fuzzy [src/]
说明
phpcpd (PHP Copy/Paste Detector) finds duplicate code in PHP projects. It identifies code that should be refactored. Token-based analysis finds similar code blocks. Renaming variables doesn't hide duplications. Thresholds control sensitivity. Higher minimums find larger, more significant duplications. Fuzzy matching finds near-duplicates. Code with minor differences is also detected. Reports show file locations and duplicated content. Integration with CI tools enables automated checks.
参数
- --min-lines _N_
- Minimum lines for duplication.
- --min-tokens _N_
- Minimum tokens for duplication.
- --exclude _DIR_
- Exclude directory.
- --log-pmd _FILE_
- PMD-CPD XML format.
- --fuzzy
- Fuzzy matching.
- --suffix _EXT_
- File suffix to check.
- -v, --verbose
- Verbose output.
- --help
- Show help.
FAQ
What is the phpcpd command used for?
phpcpd (PHP Copy/Paste Detector) finds duplicate code in PHP projects. It identifies code that should be refactored. Token-based analysis finds similar code blocks. Renaming variables doesn't hide duplications. Thresholds control sensitivity. Higher minimums find larger, more significant duplications. Fuzzy matching finds near-duplicates. Code with minor differences is also detected. Reports show file locations and duplicated content. Integration with CI tools enables automated checks.
How do I run a basic phpcpd example?
Run `phpcpd [src/]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --min-lines _N_ do in phpcpd?
Minimum lines for duplication.