Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of how to customize the ShortVariable rule in PHP Mess Detector
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom Naming Rules"
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>
Customizations for the naming rule sets. Do not include the naming ruleset in the options.
This customization pulls all naming rules in and overrides some properties.
</description>
<rule ref="rulesets/naming.xml">
<!-- To be able to customize a property on the ShortVariable rule it must first be excluded.
Does not really make sense, but see https://github.com/phpmd/phpmd/issues/33 for details. -->
<exclude name="ShortVariable"/>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<!-- Add common variable names that should be excepted from the default minimum property value of 3 -->
<property name="exceptions" description="Comma-separated list of exceptions" value="id"/>
</properties>
</rule>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.