Reputation: 2155
I'm new to using PHP Mess Detector (PHPMD) and want to teak some of the parameters. For example, the naming rules are giving me output like this:
"Avoid variables with short names like $id. Configured minimum length is 3."
Can I change the "configured minimum length" without copying and altering the XML ruleset file?
The message suggests to me that the user of this ruleset can configure these boundaries, and in the Naming Rules docs are "properties" summaries for each method with a "default value".
Can I specify properties on the command line, or is there a general config file somewhere?
Upvotes: 3
Views: 2508
Reputation: 766
When you are using configuration file you can override properties like this
phpmd /path/to/source text codesize,/my/rules.xml
<!--/my/rules.xml-->
<?xml version="1.0"?>
<ruleset name="Some 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">
<!--The part you are interested in-->
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="minimum" description="Minimum length for a variable, property or parameter name" value="2"/>
</properties>
</rule>
Upvotes: 0
Reputation: 1116
I'm afraid you will have to copy and alter the ruleset file. PHPMD does not support clanging properties on the command line.
Upvotes: 2