The class ReachabilityChecker has 23 public methods. Consider refactoring ReachabilityChecker to keep number of public methods under 10. Open
final class ReachabilityChecker extends KindVisitorImplementation
{
/** @var Node the node we're checking for reachability. */
private $inner;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class ReachabilityChecker has an overall complexity of 54 which is very high. The configured complexity threshold is 50. Open
final class ReachabilityChecker extends KindVisitorImplementation
{
/** @var Node the node we're checking for reachability. */
private $inner;
- Exclude checks
ReachabilityChecker
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
final class ReachabilityChecker extends KindVisitorImplementation
{
/** @var Node the node we're checking for reachability. */
private $inner;
Function visitStmtList
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function visitStmtList(Node $node): ?bool
{
foreach ($node->children as $child) {
if (!($child instanceof Node)) {
continue;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function visitConditional
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitConditional(Node $node): ?bool
{
$cond = $node->children['cond'];
if ($cond instanceof Node) {
$result = $this->__invoke($cond);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function visit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visit(Node $node): ?bool
{
foreach ($node->children as $child) {
if (!($child instanceof Node)) {
continue;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"