Skip to content

Commit

Permalink
Remove method calculation in coverage metrics
Browse files Browse the repository at this point in the history
This commit simplifies the coverage metrics calculation by eliminating the counting of method-specific metrics. The focus is now solely on conditionals and statements, ensuring more streamlined and potentially faster processing.
  • Loading branch information
jonnynews committed Nov 1, 2024
1 parent 2d01b74 commit 8e4af5f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/BadgeComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,18 @@ private function processFile(string $inputFile): void

$totalConditionals = 0;
$totalStatements = 0;
$totalMethods = 0;
$coveredStatements = 0;
$coveredConditionals = 0;
$coveredMethods = 0;

foreach ($metrics as $metric) {
$totalConditionals += (int) $metric['conditionals'];
$coveredConditionals += (int) $metric['coveredconditionals'];
$totalStatements += (int) $metric['statements'];
$coveredStatements += (int) $metric['coveredstatements'];
$totalMethods += (int) $metric['methods'];
$coveredMethods += (int) $metric['coveredmethods'];
}

$totalElements = $totalConditionals + $totalStatements + $totalMethods;
$coveredElements = $coveredConditionals + $coveredStatements + $coveredMethods;
$totalElements = $totalConditionals + $totalStatements;
$coveredElements = $coveredConditionals + $coveredStatements;
$coverageRatio = $totalElements ? $coveredElements / $totalElements : 0;
$this->totalCoverage[] = (int) round($coverageRatio * 100);

Expand Down

0 comments on commit 8e4af5f

Please sign in to comment.