/usr/share/php/data/PHP_PMD/resources/rulesets/naming.xml is in phpmd 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | <?xml version="1.0" encoding="UTF-8"?>
<ruleset name="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>
The Naming Ruleset contains a collection of rules about names - too long, too short, and so forth.
</description>
<rule name="ShortVariable"
since="0.2"
message="Avoid variables with short names like {0}. Configured minimum length is {1}."
class="PHP_PMD_Rule_Naming_ShortVariable"
externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable">
<description>
Detects when a field, local, or parameter has a very short name.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="Minimum length for a variable, property or parameter name" value="3"/>
<property name="exceptions" description="Comma-separated list of exceptions" value=""/>
</properties>
<example>
<![CDATA[
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
]]>
</example>
</rule>
<rule name="LongVariable"
since="0.2"
message="Avoid excessively long variable names like {0}. Keep variable name length under {1}."
class="PHP_PMD_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="20"/>
</properties>
<example>
<![CDATA[
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $argumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
]]>
</example>
</rule>
<rule name="ShortMethodName"
since="0.2"
message="Avoid using short method names like {0}::{1}(). The configured minimum method name length is {2}."
class="PHP_PMD_Rule_Naming_ShortMethodName"
externalInfoUrl="http://phpmd.org/rules/naming.html#shortmethodname">
<description>
Detects when very short method names are used.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="Minimum length for a method or function name" value="3"/>
</properties>
<example>
<![CDATA[
class ShortMethod {
public function a( $index ) { // Violation
}
}
]]>
</example>
</rule>
<rule name="ConstructorWithNameAsEnclosingClass"
since="0.2"
message="Classes should not have a constructor method with the same name as the class"
class="PHP_PMD_Rule_Naming_ConstructorWithNameAsEnclosingClass"
externalInfoUrl="http://phpmd.org/rules/naming.html#constructorwithnameasenclosingclass">
<description>
A constructor method should not have the same name as the enclosing class, consider
to use the PHP 5 __construct method.
</description>
<priority>3</priority>
<example>
<![CDATA[
class MyClass {
// this is bad because it is PHP 4 style
public function MyClass() {}
// this is good because it is a PHP 5 constructor
public function __construct() {}
}
]]>
</example>
</rule>
<rule name="ConstantNamingConventions"
since="0.2"
message="Constant {0} should be defined in uppercase"
class="PHP_PMD_Rule_Naming_ConstantNamingConventions"
externalInfoUrl="http://phpmd.org/rules/naming.html#constantnamingconventions">
<description>
Class/Interface constant nanmes should always be defined in uppercase.
</description>
<priority>4</priority>
<properties />
<example>
<![CDATA[
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
]]>
</example>
</rule>
<rule name="BooleanGetMethodName"
since="0.2"
message="The '{0}()' method which returns a boolean should be named 'is...()' or 'has...()'"
class="PHP_PMD_Rule_Naming_BooleanGetMethodName"
externalInfoUrl="http://phpmd.org/rules/naming.html#booleangetmethodname">
<description>
Looks for methods named 'getX()' with 'boolean' as the return type. The convention
is to name these methods 'isX()' or 'hasX()'.
</description>
<priority>4</priority>
<properties>
<property name="checkParameterizedMethods" value="false" description="Applies only to methods without parameter when set to true" />
</properties>
<example>
<![CDATA[
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
]]>
</example>
</rule>
<!--
<rule name="VariableNamingConventions"
since="1.2"
message="{0} variable {1} should begin with {2}"
class="net.sourceforge.pmd.rules.VariableNamingConventions"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#VariableNamingConventions">
<description>
A variable naming conventions rule - customize this to your liking. Currently, it
checks for final variables that should be fully capitalized and non-final variables
that should not include underscores.
</description>
<priority>1</priority>
<properties>
<property name="staticPrefix" description="A prefix for static variables" value=""/>
<property name="staticSuffix" description="A suffix for static variables" value=""/>
<property name="memberPrefix" description="A prefix for member variables" value=""/>
<property name="memberSuffix" description="A suffix for member variables" value=""/>
</properties>
<example>
<![CDATA[
public class Foo {
public static final int MY_NUM = 0;
public String myTest = "";
DataModule dmTest = new DataModule();
}
]]>
</example>
</rule>
<rule name="MethodNamingConventions"
since="1.2"
message="Method name does not begin with a lower case character."
class="net.sourceforge.pmd.rules.MethodNamingConventions"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#MethodNamingConventions">
<description>
Method names should always begin with a lower case character, and should not contain underscores.
</description>
<priority>1</priority>
<example>
<![CDATA[
public class Foo {
public void fooStuff() {
}
}
]]>
</example>
</rule>
<rule name="ClassNamingConventions"
since="1.2"
message="Class names should begin with an uppercase character"
class="net.sourceforge.pmd.rules.ClassNamingConventions"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#ClassNamingConventions">
<description>
Class names should always begin with an upper case character.
</description>
<priority>1</priority>
<example>
<![CDATA[
public class Foo {}
]]>
</example>
</rule>
<rule name="AbstractNaming"
since="1.4"
message="Abstract classes should be named 'AbstractXXX'"
class="net.sourceforge.pmd.rules.XPathRule"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#AbstractNaming">
<description>
Abstract classes should be named 'AbstractXXX'.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration
[@Abstract='true' and @Interface='false']
[not (starts-with(@Image,'Abstract'))]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
public abstract class Foo { // should be AbstractFoo
}
]]>
</example>
</rule>
<rule name="AvoidFieldNameMatchingTypeName"
since="3.0"
message="It is somewhat confusing to have a field name matching the declaring class name"
class="net.sourceforge.pmd.rules.AvoidFieldNameMatchingTypeName"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#AvoidFieldNameMatchingTypeName">
<description>
It is somewhat confusing to have a field name matching the declaring class name.
This probably means that type and or field names could be more precise.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo extends Bar {
// There's probably a better name for foo
int foo;
}
]]>
</example>
</rule>
<rule name="AvoidFieldNameMatchingMethodName"
since="3.0"
message="It is somewhat confusing to have a field name with the same name as a method"
class="net.sourceforge.pmd.rules.AvoidFieldNameMatchingMethodName"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#AvoidFieldNameMatchingMethodName">
<description>
It is somewhat confusing to have a field name with the same name as a method.
While this is totally legal, having information (field) and actions (method) is
not clear naming.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
Object bar;
// bar is data or an action or both?
void bar() {
}
}
]]>
</example>
</rule>
<rule name="NoPackage"
since="3.3"
message="All classes and interfaces must belong to a named package"
class="net.sourceforge.pmd.rules.XPathRule"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#NoPackage">
<description>
Detects when a class or interface does not have a package definition.
</description>
<priority>3</priority>
<properties>
<property name="xpath" pluginname="true">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration[count(preceding::PackageDeclaration) = 0]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
// no package declaration
public class ClassInDefaultPackage {
}
]]>
</example>
</rule>
<rule name="MisleadingVariableName"
since="3.4"
message="Avoid naming non-fields with the prefix 'm_'"
class="net.sourceforge.pmd.rules.XPathRule"
externalInfoUrl="http://pmd.sourceforge.net/rules/naming.html#MisleadingVariableName">
<description>
Detects when a non-field has a name starting with 'm_'. This usually
indicates a field and thus is confusing.
</description>
<priority>3</priority>
<properties>
<property name="xpath" pluginname="true">
<value>
<![CDATA[
//VariableDeclaratorId
[starts-with(@Image, 'm_')]
[not (../../../FieldDeclaration)]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
public class Foo {
private int m_foo; // OK
public void bar(String m_baz) { // Bad
int m_boz = 42; // Bad
}
}
]]>
</example>
</rule>
-->
</ruleset>
|