-
Notifications
You must be signed in to change notification settings - Fork 3
/
.phpmd.cleancode.xml
70 lines (66 loc) · 2.41 KB
/
.phpmd.cleancode.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
<?xml version="1.0"?>
<ruleset name="Clean Code 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 Clean Code ruleset contains rules that enforce a clean code base. This includes rules from SOLID and object calisthenics.
</description>
<rule name="BooleanArgumentFlag"
since="1.4.0"
message="The method {0} has a boolean flag argument {1}, which is a certain sign of a Single Responsibility Principle violation."
class="PHPMD\Rule\CleanCode\BooleanArgumentFlag"
externalInfoUrl="https://phpmd.org/rules/cleancode.html#booleanargumentflag">
<description>
<![CDATA[
A boolean flag argument is a reliable indicator for a violation of
the Single Responsibility Principle (SRP). You can fix this problem
by extracting the logic in the boolean flag into its own class
or method.
]]>
</description>
<priority>1</priority>
<properties />
<example>
<![CDATA[
class Foo {
public function bar($flag = true) {
}
}
]]>
</example>
</rule>
<rule name="ElseExpression"
since="1.4.0"
message="The method {0} uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them."
class="PHPMD\Rule\CleanCode\ElseExpression"
externalInfoUrl="https://phpmd.org/rules/cleancode.html#elseexpression">
<description>
<![CDATA[
An if expression with an else branch is basically not necessary. You can rewrite the
conditions in a way that the else clause is not necessary and the code becomes simpler
to read. To achieve this, use early return statements, though you may
need to split the code it several smaller methods. For very simple assignments
you could also use the ternary operations.
]]>
</description>
<priority>1</priority>
<properties/>
<example>
<![CDATA[
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
]]>
</example>
</rule>
</ruleset>