/usr/share/php/data/PHP_PMD/resources/rulesets/cleancode.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 | <?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="PHP_PMD_Rule_CleanCode_BooleanArgumentFlag"
externalInfoUrl="http://phpmd.org/rules/design.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 is never necessary and you can simplify the code to work without else."
class="PHP_PMD_Rule_CleanCode_ElseExpression"
externalInfoUrl="http://phpmd.org/rules/design.html#eleseexpression">
<description>
<![CDATA[
An if expression with an else branch is never necessary. You can rewrite the
conditions in a way that the else is not necessary and the code becomes simpler to read.
To achieve this use early exits or partition the method it several smaller methods.
]]>
</description>
<priority>1</priority>
<properties></properties>
<example>
<![CDATA[
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
]]>
</example>
</rule>
<rule name="StaticAccess"
since="1.4.0"
message="Avoid using static access to class '{0}' in method '{1}'."
class="PHP_PMD_Rule_CleanCode_StaticAccess"
externalInfoUrl="http://phpmd.org/rules/design.html#staticaccess">
<description>
<![CDATA[
Static acccess causes inexchangable dependencies to other classes and leads to hard to test code. Avoid
using static access at all costs and instead inject dependencies through the constructor. The only
case when static access is acceptable is when used for factory methods.
]]>
</description>
<priority>1</priority>
<properties></properties>
<example>
<![CDATA[
class Foo
{
public function bar()
{
Bar::baz();
}
}
]]>
</example>
</rule>
<rule name="NestedScopes"
since="1.4.0"
message="The method {0} uses a nested scope. Nested scopes increase complexity and should be extracted into their own mehtods."
class="PHP_PMD_Rule_CleanCode_NestedScopes"
externalInfoUrl="http://phpmd.org/rules/design.html#nestedscopes">
<description>
<![CDATA[
A nested scope is a loop in a loop, or an if-statement inside an if-statement. These blocks
of code are usually subject to increased complexity and make the code hard to read.
Consider extracting nested scopes into their own helper methods.
]]>
</description>
<priority>1</priority>
<properties></properties>
<example>
<![CDATA[
class Foo
{
public function bar($flag)
{
if ($flag) {
if ($this->otherCondition($flag)) {
// nested scope here
}
} else {
// another branch
}
}
}
]]>
</example>
</rule>
</ruleset>
|