The Clean Code ruleset contains rules that enforce a clean code base. This includes rules from SOLID and object calisthenics.
1
1
1
The Code Size Ruleset contains a collection of rules that find code size related problems.
3
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.
3
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.
3
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.
3
Long parameter lists can indicate that a new object should be created to
wrap the numerous parameters. Basically, try to group the parameters together.
3
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.
3
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.
3
3
3
3
This ruleset contains a collection of controversial rules.
1
1
1
1
1
1
The Design Ruleset contains a collection of rules that find software design related problems.
1
1
1
2
2
2
2
$item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
]]>
The Naming Ruleset contains a collection of rules about names - too long, too short, and so forth.
Detects when a field, local, or parameter has a very short name.
3
q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
]]>
Detects when a field, formal or local variable is declared with a long name.
3
Detects when very short method names are used.
3
A constructor method should not have the same name as the enclosing class, consider
to use the PHP 5 __construct method.
3
Class/Interface constant names should always be defined in uppercase.
4
Looks for methods named 'getX()' with 'boolean' as the return type. The convention
is to name these methods 'isX()' or 'hasX()'.
4
The Unused Code Ruleset contains a collection of rules that find unused code.
Detects when a private field is declared and/or assigned a value, but not used.
3
j++;
}
}
]]>
Detects when a local variable is declared and/or assigned, but not used.
3
Unused Private Method detects when a private method is declared but is unused.
3
Avoid passing parameters to methods or constructors and then not using those parameters.
3