/usr/share/php/data/PHP_PMD/resources/rulesets/codesize.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 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | <?xml version="1.0" encoding="UTF-8" ?>
<ruleset name="Code Size 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 Code Size Ruleset contains a collection of rules that find code size related problems.
</description>
<rule name="CyclomaticComplexity"
since="0.1"
message = "The {0} {1}() has a Cyclomatic Complexity of {2}. The configured cyclomatic complexity threshold is {3}."
class="PHP_PMD_Rule_CyclomaticComplexity"
externalInfoUrl="http://phpmd.org/rules/codesize.html#cyclomaticcomplexity">
<description>
<![CDATA[
Complexity is determined by the number of decision points in a method plus one for the
method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally,
1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity,
and 11+ is very high complexity.
]]>
</description>
<priority>3</priority>
<properties>
<property name="reportLevel" description="The Cyclomatic Complexity reporting threshold" value="10"/>
<property name="showClassesComplexity"
description="Indicate if class average violation should be added to the report"
value="true"/>
<property name="showMethodsComplexity"
description="Indicate if class average violation should be added to the report"
value="true"/>
</properties>
<example>
<![CDATA[
// Cyclomatic Complexity = 12
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } else if ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } else if ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } else if ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else{
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
12 default:
fiddle();
break;
}
}
}
}
]]>
</example>
</rule>
<rule name="NPathComplexity"
since="0.1"
message="The {0} {1}() has an NPath complexity of {2}. The configured NPath complexity threshold is {3}."
class="PHP_PMD_Rule_Design_NpathComplexity"
externalInfoUrl="http://phpmd.org/rules/codesize.html#npathcomplexity">
<description>
The NPath complexity of a method is the number of acyclic execution paths through that method.
A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The npath reporting threshold" value="200"/>
</properties>
<example>
<![CDATA[
class Foo {
function bar() {
// lots of complicated code
}
}
]]>
</example>
</rule>
<rule name="ExcessiveMethodLength"
since="0.1"
message="The {0} {1}() has {2} lines of code. Current threshold is set to {3}. Avoid really long methods."
class="PHP_PMD_Rule_Design_LongMethod"
externalInfoUrl="http://phpmd.org/rules/codesize.html#excessivemethodlength">
<description>
Violations of this rule usually indicate that the method is doing
too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The method size reporting threshold" value="100"/>
</properties>
<example>
<![CDATA[
class Foo {
public function doSomething() {
print("Hello world!" . PHP_EOL);
print("Hello world!" . PHP_EOL);
// 98 copies omitted for brevity.
}
}
]]>
</example>
</rule>
<rule name="ExcessiveClassLength"
since="0.1"
message="The class {0} has {1} lines of code. Current threshold is {2}. Avoid really long classes."
class="PHP_PMD_Rule_Design_LongClass"
externalInfoUrl="http://phpmd.org/rules/codesize.html#excessiveclasslength">
<description>
Long Class files are indications that the class may be trying to
do too much. Try to break it down, and reduce the size to something
manageable.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The class size reporting threshold" value="1000"/>
</properties>
<example>
<![CDATA[
class Foo {
public function bar() {
// 1000 lines of code
}
}
]]>
</example>
</rule>
<rule name="ExcessiveParameterList"
since="0.1"
message="The {0} {1} has {2} parameters. Consider to reduce parameter number under {3}."
class="PHP_PMD_Rule_Design_LongParameterList"
externalInfoUrl="http://phpmd.org/rules/codesize.html#excessiveparameterlist">
<description>
Long parameter lists can indicate that a new object should be created to
wrap the numerous parameters. Basically, try to group the parameters together.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The parameter count reporting threshold" value="10"/>
</properties>
<example>
<![CDATA[
class Foo {
public function addData(
$p0, $p1, $p2, $p3, $p4, $p5,
$p5, $p6, $p7, $p8, $p9, $p10) {
}
}
]]>
</example>
</rule>
<rule name="ExcessivePublicCount"
since="0.1"
message="The {0} {1} has {2} public methods and attributes. Consider to reduce the number of public items under {3}."
class="PHP_PMD_Rule_ExcessivePublicCount"
externalInfoUrl="http://phpmd.org/rules/codesize.html#excessivepubliccount">
<description>
A large number of public methods and attributes declared in a class can indicate
the class may need to be broken up as increased effort will be required to
thoroughly test it.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The public item reporting threshold" value="45"/>
</properties>
<example>
<![CDATA[
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
]]>
</example>
</rule>
<rule name="TooManyFields"
since="0.1"
message="The {0} {1} has {2} fields. Consider to redesign {1} to keep the number of fields under {3}."
class="PHP_PMD_Rule_Design_TooManyFields"
externalInfoUrl="http://phpmd.org/rules/codesize.html#toomanyfields">
<description>
Classes that have too many fields could be redesigned to have fewer fields,
possibly through some nested object grouping of some of the information. For
example, a class with city/state/zip fields could instead have one Address
field.
</description>
<priority>3</priority>
<properties>
<property name="maxfields" description="The field count reporting threshold " value="15"/>
</properties>
<example>
<![CDATA[
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
]]>
</example>
</rule>
<!--
<rule name="NcssMethodCount" message="The method {0}() has an NCSS line count of {1}"
since="3.9"
class="net.sourceforge.pmd.rules.codesize.NcssMethodCount"
externalInfoUrl="http://pmd.sourceforge.net/rules/codesize.html#NcssMethodCount">
<description>
This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines
of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm,
lines of code that are split are counted as one.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The method NCSS count reporting threshold" value="100"/>
</properties>
<example>
<![CDATA[
public class Foo extends Bar {
public int methd() {
super.methd();
//this method only has 1 NCSS lines
return 1;
}
}
]]>
</example>
</rule>
<rule name="NcssTypeCount" message="The type has an NCSS line count of {0}"
since="3.9"
class="net.sourceforge.pmd.rules.codesize.NcssTypeCount"
externalInfoUrl="http://pmd.sourceforge.net/rules/codesize.html#NcssTypeCount">
<description>
This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines
of code for a given type. NCSS ignores comments, and counts actual statements. Using this algorithm,
lines of code that are split are counted as one.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The type NCSS count reporting threshold" value="1500"/>
</properties>
<example>
<![CDATA[
public class Foo extends Bar {
public Foo() {
//this class only has 6 NCSS lines
super();
super.foo();
}
}
]]>
</example></rule>
<rule name="NcssConstructorCount" message="The constructor with {0} parameters has an NCSS line count of {1}"
since="3.9"
class="net.sourceforge.pmd.rules.codesize.NcssConstructorCount"
externalInfoUrl="http://pmd.sourceforge.net/rules/codesize.html#NcssConstructorCount">
<description>
This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines
of code for a given constructor. NCSS ignores comments, and counts actual statements. Using this algorithm,
lines of code that are split are counted as one.
</description>
<priority>3</priority>
<properties>
<property name="minimum" description="The constructor NCSS count reporting threshold" value="100"/>
</properties>
<example>
<![CDATA[
public class Foo extends Bar {
public Foo() {
super();
//this constructor only has 1 NCSS lines
super.foo();
}
}
]]>
</example>
</rule>
-->
<rule name="TooManyMethods"
since="0.1"
class="PHP_PMD_Rule_Design_TooManyMethods"
message="The {0} {1} has {2} methods. Consider refactoring {1} to keep number of methods under {3}."
externalInfoUrl="http://phpmd.org/rules/codesize.html#toomanymethods">
<description>
<![CDATA[
A class with too many methods is probably a good suspect for refactoring, in
order to reduce its complexity and find a way to have more fine grained objects.
]]>
</description>
<priority>3</priority>
<properties>
<property name="maxmethods" description="The method count reporting threshold " value="10"/>
</properties>
</rule>
<rule name="ExcessiveClassComplexity"
since="0.2.5"
class="PHP_PMD_Rule_Design_WeightedMethodCount"
message="The class {0} has an overall complexity of {1} which is very high. The configured complexity threshold is {2}."
externalInfoUrl="http://phpmd.org/rules/codesize.html#excessiveclasscomplexity">
<description>
<![CDATA[
The WMC of a class is a good indicator of how much time and effort is required
to modify and maintain this class. A large number of methods also means that
this class has a greater potential impact on derived classes.
]]>
</description>
<priority>3</priority>
<properties>
<property name="maximum" description="The maximum WMC tolerable for a class." value="50"/>
</properties>
<example>
<![CDATA[
class Foo {
public function bar() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} else if ($a2 == $b2) {
fiddle();
} else {
}
}
}
public function baz() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} else if ($a2 == $b2) {
fiddle();
} else {
}
}
}
// Several other complex methods
}
]]>
</example>
</rule>
</ruleset>
|