1

Can anyone tell me why under PHPSTORM 2017.1 and PHPMD 2.6.0 some configuration options doesn't work:

  • ShortVariable

PhpStorm mark variable

private $id;

as "Configured minimum length is 3"

  • ignore field TooManyFields

PhpStorm show: "The class X has 21 fields. Consider rising X to keep the number of fields under 15". I searched and saw many articles but no one works for me.

<?xml version="1.0"?>
<ruleset name="MyProject Mess Detector rule set"
         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>
        MyProject Mess Detector
    </description>
    <rule ref="rulesets/cleancode.xml">
        <exclude name="StaticAccess"/>
    </rule>
    <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
        <priority>1</priority>
        <properties>
            <property name="reportLevel" value="9" />
        </properties>
    </rule>
    <rule ref="rulesets/naming.xml">
        <exclude name="ShortVariable"/>
    </rule>
    <rule ref="rulesets/naming.xml/ShortVariable"
          since="0.2"
          message="Avoid variables with short names like {0}. Configured minimum length is {1}."
          class="PHPMD\Rule\Naming\ShortVariable"
          externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable">
        <priority>3</priority>
        <properties>
            <property name="minimum" value="2" />
            <property name="exceptions" value="id" />
        </properties>
    </rule>
    <rule ref="rulesets/codesize.xml">
        <exclude name="TooManyFields"/>
    </rule>
    <rule ref="rulesets/unusedcode.xml" />
</ruleset>
Arkowsky
  • 851
  • 7
  • 19
  • Did you add your custom ruleset to PHP | PHP Mess Detector validation inspection settings? Can you see these rules working when running PHPMD from command line? – Vlad Luchansky Jun 25 '17 at 16:50
  • Thanks Vlad for your answer. I have added my ruleset to inspection settings in PHPStorm(and settings reportLevel works fine) but others settings doesn't work. I will try to run this from cmd line and let you know. As I said before - it looks like some options works but some not. – Arkowsky Jun 26 '17 at 08:31
  • Feel free to contact us via PhpStorm > Help > New Support Request if the issue will remain. – Vlad Luchansky Jun 26 '17 at 23:03

0 Answers0