Skip to content

Instantly share code, notes, and snippets.

@guilu
Last active September 7, 2015 09:11
Show Gist options
  • Save guilu/1d1e268375b1819c79b9 to your computer and use it in GitHub Desktop.
Save guilu/1d1e268375b1819c79b9 to your computer and use it in GitHub Desktop.
Rulesets del mess detector. Suele ir en ci/phpmd.xml
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset name="My own 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>
Son todas las reglas de phpmd, pero con algunas excepciones :
- Clean Code: quita el warning de sentencias else
- Clean code: quita el warning de acceso a static objects.
- Naming: Para las variables cortas, el mínimo sigue siendo 3, pero no cuentan iteradores, em (entity manager), etc.
- Naming: Para las variables largas el nuevo máximo es 25.
</description>
<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/cleancode.xml">
<exclude name="ElseExpression"/>
<exclude name="StaticAccess"/>
</rule>
<rule ref="rulesets/controversial.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable" />
<exclude name="LongVariable" />
</rule>
<rule name="ShortVariables"
ref="rulesets/naming.xml/ShortVariable"
since="0.1"
message="Evita variables con nombres cortos como {0}. La mínima longitud es {1}."
class="PHP_PMD_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" />
</properties>
</rule>
<rule name="LongVariables"
ref="rulesets/naming.xml/LongVariable"
since="0.1"
message="Evita variables con nombres largos como {0}. La máxima longitud es {1}."
class="PHP_PMD_Rule_Naming_ShortVariable"
externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable">
<priority>3</priority>
<properties>
<property name="maximum" description="Maximum length for a variable, property or parameter name" value="25"/>
</properties>
</rule>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment