Skip to content

Conversation

jlaso
Copy link
Contributor

@jlaso jlaso commented Jun 15, 2016

Often you going to need to explicitly pass Mess Detector without minimum-priority parameter or with a specific one.
This PR solves that cases.

@jlaso
Copy link
Contributor Author

jlaso commented Jun 16, 2016

That is the result for a file that has problems with my PmdRules.xml

command used:

phpmd MyMDtest.php text PmdRules.xml --minimumpriority 1

output:

none (that means all it's okay)


Now removing the --minimumpriority clause

phpmd MyMDtest.php text PmdRules.xml

output:

MyMDtest.php:42 The method generateCollection() has an NPath complexity of 1802. The configured NPath complexity threshold is 200.
MyMDtest.php:114 The method generateEnvironment() has an NPath complexity of 15625. The configured NPath complexity threshold is 200.


The file of rules I am using is

<?xml version="1.0"?>
<ruleset name="Mytest Ruleset" 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>
        Mytest ruleset.
    </description>
    <rule ref="rulesets/design.xml"/>
    <rule ref="rulesets/unusedcode.xml"/>
    <rule ref="rulesets/codesize.xml"/>


    <rule ref="rulesets/naming.xml">
        <exclude name="LongVariable"/>
        <exclude name="ShortVariable"/>
        <exclude name="ShortMethodName"/>
        <exclude name="BooleanGetMethodName"/>
    </rule>

    <rule ref="rulesets/naming.xml/ShortVariable"
          since="0.2"
          message="Avoid variables with short names like {0}. Minimum length is {1}."
          class="PHPMD\Rule\Naming\ShortVariable"
          externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable">
        <priority>3</priority>
        <properties>
            <property name="minimum" description="Minimum length for a variable, property or parameter name" value="3"/>
            <property name="exceptions" value="id,q,w,i,j,v,e,f,fp,em,qb"/>
        </properties>
    </rule>

    <rule ref="rulesets/naming.xml/LongVariable"
          since="0.2"
          message="Avoid excessively long variable names like {0}. Keep variable name length under {1}."
          class="PHPMD\Rule\Naming\LongVariable"
          externalInfoUrl="http://phpmd.org/rules/naming.html#longvariable">
        <description>
            Detects when a field, formal or local variable is declared with a long name.
        </description>
        <priority>3</priority>
        <properties>
            <property name="maximum" description="The variable length reporting threshold" value="25"/>
        </properties>
    </rule>

    <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
        <priority>1</priority>
        <properties>
            <property name="reportLevel" value="10"/>
        </properties>
    </rule>
</ruleset>

@bruli bruli closed this Jun 24, 2016
@bruli
Copy link
Owner

bruli commented Jun 24, 2016

Added in last release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants