【PHP】代码质量检查工具PHPMD
除了PHPCS外,再给大家推荐一个代码质量检查工具PHPMD。
项目官网:https://phpmd.org
用法
# phpmd 代码路径 报告格式 规则xml文件 phpmd /path/to/source text /phpmd_ruleset.xml # phpmd 代码路径 报告格式 规则列表 phpmd /path/to/source text codesize,unusedcode,naming
安装
wget -c http://static.phpmd.org/php/latest/phpmd.phar
提供一个配置,大家可以参考自定义自己的规则,所有的可用和可排除的规则在这里
<?xml version="1.0"?> <ruleset name="PHPMD Rule Sets" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd"> <description> PHPMD rule sets to check php codes. </description> <!-- Import the clean code rule set --> <rule ref="rulesets/cleancode.xml"> <exclude name="BooleanArgumentFlag" /> <exclude name="ElseExpression" /> <exclude name="StaticAccess" /> </rule> <!-- Import the code size rule set --> <rule ref="rulesets/codesize.xml" /> <!-- Import the entire unused code rule set --> <rule ref="rulesets/controversial.xml" /> <!-- Import the design rule set --> <rule ref="rulesets/design.xml" /> <!-- Import the entire unused code rule set --> <rule ref="rulesets/naming.xml" /> <!-- Import the entire unused code rule set --> <rule ref="rulesets/unusedcode.xml" /> </ruleset>
更多帮助可以直接看官方文档
标签: PHP
还没有人抢沙发呢~