-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpmd.xml
112 lines (104 loc) · 3.97 KB
/
phpmd.xml
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
<?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="PHPMD\Rule\CyclomaticComplexity"
externalInfoUrl="https://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="15"/>
<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 = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($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;
default:
fiddle();
break;
}
}
}
}
]]>
</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="PHPMD\Rule\Design\LongMethod"
externalInfoUrl="https://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="115"/>
<property name="ignore-whitespace" description="Count whitespace in reporting threshold" value="false"/>
</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>
<exclude-pattern>/src/Enums/</exclude-pattern>
<exclude-pattern>/src/Withdraw/Enums/</exclude-pattern>
<exclude-pattern>/src/Antifraud/Enums/Collection/</exclude-pattern>
</ruleset>