对于我的项目,这样的警告会不断出现在Code Climate中:
我尝试更改配置,但是似乎没有任何效果。 Github项目在这里:https://github.com/cnizzardini/cakephp-yummy
奇怪的是,像ShortVariable这样的默认值是3,但我却能够更改为1。我在做什么错了?
.codeclimate.yml
---
engines:
duplication:
enabled: true
config:
languages:
- php
eslint:
enabled: true
fixme:
enabled: true
phpmd:
enabled: true
config:
file_extensions: "php"
rulesets: "unusedcode,codesize,naming,phpmd.xml"
ratings:
paths:
- "**.inc"
- "**.ctp"
- "**.module"
- "**.php"
exclude_paths:
- config/
- tests/
- webroot/
phpmd.xml
<?xml version="1.0"?>
<ruleset name="PHPMD rule set for my project" 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>Custom rules for checking my project</description>
<rule ref="rulesets/cleancode.xml">
<exclude name="ElseExpression"/>
</rule>
<rule ref="rulesets/codesize.xml">
<exclude name="TooManyPublicMethods"/>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="ignore-whitespace" value="true" />
<property name="minimum" value="100" />
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassLength">
<properties>
<property name="minimum" value="700" />
</properties>
</rule>
<rule ref="rulesets/namingrules.xml/ShortVariable">
<properties>
<property name="minimum" value="1" />
</properties>
</rule>
</ruleset>
答案 0 :(得分:-1)
首先需要
<exclude name="ExcessiveMethodLength"/>
<exclude name="ExcessiveClassLength"/>
<?xml version="1.0"?>
<ruleset name="PHPMD rule set for my project" 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>Custom rules for checking my project</description>
<rule ref="rulesets/cleancode.xml">
<exclude name="ElseExpression"/>
</rule>
<rule ref="rulesets/codesize.xml">
<exclude name="TooManyPublicMethods"/>
<exclude name="ExcessiveMethodLength"/>
<exclude name="ExcessiveClassLength"/>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="ignore-whitespace" value="true" />
<property name="minimum" value="100" />
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassLength">
<properties>
<property name="minimum" value="700" />
</properties>
</rule>
<rule ref="rulesets/namingrules.xml/ShortVariable">
<properties>
<property name="minimum" value="1" />
</properties>
</rule>
</ruleset>