Skip to content

Commit

Permalink
Fixing a bug in the visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankraemer committed Sep 24, 2024
1 parent 10c3a47 commit 6eff659
Show file tree
Hide file tree
Showing 5 changed files with 4,119 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/PhpParser/CognitiveMetricsVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ private function writeMetricsOnLeaveNode(Node $node): void
{
if ($node instanceof Node\Stmt\ClassMethod) {
$method = "{$this->currentClassName}::{$this->currentMethod}";
$this->methodMetrics[$method]['return_count'] = $this->currentReturnCount;
$this->methodMetrics[$method]['variable_count'] = count($this->currentVariables);
$this->methodMetrics[$method]['property_call_count'] = $this->propertyCalls;
$this->methodMetrics[$method]['if_count'] = $this->ifCount;
$this->methodMetrics[$method]['if_nesting_level'] = $this->maxIfNestingLevel;
$this->methodMetrics[$method]['else_count'] = $this->elseCount;
$this->methodMetrics[$method]['line_count'] = $node->getEndLine() - $node->getStartLine() + 1;
$this->methodMetrics[$method]['arg_count'] = count($node->getParams());
$this->methodMetrics[$method]['returnCount'] = $this->currentReturnCount;
$this->methodMetrics[$method]['variableCount'] = count($this->currentVariables);
$this->methodMetrics[$method]['propertyCallCount'] = $this->propertyCalls;
$this->methodMetrics[$method]['ifCount'] = $this->ifCount;
$this->methodMetrics[$method]['ifNestingLevel'] = $this->maxIfNestingLevel;
$this->methodMetrics[$method]['elseCount'] = $this->elseCount;
$this->methodMetrics[$method]['lineCount'] = $node->getEndLine() - $node->getStartLine() + 1;
$this->methodMetrics[$method]['argCount'] = count($node->getParams());
$this->currentMethod = '';
}
}
Expand Down
Loading

0 comments on commit 6eff659

Please sign in to comment.