1
votes

Warnings like this keep popping up in Code Climate for my project:

  • File YummySearchComponent.php has 360 lines of code (exceeds 250 allowed). Consider refactoring.
  • Method getYummyHelperData has 43 lines of code (exceeds 25 allowed). Consider refactoring.

I have tried altering the configurations but nothing seems to be working. Github project is here: https://github.com/cnizzardini/cakephp-yummy

What's strange is ones like ShortVariable worked as it defaults to 3, but I was able to change to 1. What am I doing wrong?

.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>
1

1 Answers

-1
votes

First you need

<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>