Skip to content

Commit 03a054a

Browse files
committed
Improve CRAP index calculation
1 parent ece0ca1 commit 03a054a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
"cs": "phpcs -s -p --report=full --standard=phpcs.xml.dist",
6565
"psalm": "psalm --long-progress --output-format=compact --config=psalm.xml.dist",
6666
"phpmd": "phpmd src ansi phpmd.xml.dist --suffixes php",
67-
"pdepend": "pdepend --summary-xml=summary.xml --suffix=php --quiet src"
67+
"pdepend": "pdepend --summary-xml=.summary.xml --suffix=php --quiet src",
68+
"check": [
69+
"@lint",
70+
"@cs",
71+
"@psalm",
72+
"@phpmd"
73+
]
6874
}
6975
}

src/AndreyTech/Pdepend/Summary/Extractor/Parser.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use Exception;
2121
use SimpleXMLElement;
2222

23+
use function round;
24+
2325
final class Parser
2426
{
2527
/**
@@ -216,7 +218,7 @@ private function calculateCRAP(int $complexity, int $coverage = 0): int
216218
{
217219
$crap = ($complexity ** 2) * ((1 - $coverage / 100) ** 3) + $complexity;
218220

219-
return (int) $crap;
221+
return (int) round($crap);
220222
}
221223

222224
private function getStringAttr(SimpleXMLElement $element, string $attribute): string

0 commit comments

Comments
 (0)