Невозможно изменить ExcessiveMethodLength на phpmd через codeclimate - PullRequest
0 голосов
/ 08 сентября 2018

Предупреждения, подобные этому, продолжают появляться в Code Climate для моего проекта:

  • Файл YummySearchComponent.php содержит 360 строк кода (превышает 250 позволил). Рассмотрим рефакторинг.
  • Метод getYummyHelperData имеет 43 строки кода (более 25 допустимых). Рассмотрим рефакторинг.

Я пытался изменить настройки, но, похоже, ничего не работает. Проект 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>

1 Ответ

0 голосов
/ 09 августа 2019

Сначала вам нужно

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