Skip to content

Commit 8bf1284

Browse files
committed
Improve CARP calculation
1 parent 21c588a commit 8bf1284

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/PHPUnit/Cobertura/Formatter/Parser/Crap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace AndreyTech\PHPUnit\Cobertura\Formatter\Parser;
1313

1414
use function pow;
15+
use function round;
1516

1617
final class Crap
1718
{
@@ -22,6 +23,6 @@ public function calculate(int $complexity, float $coverage): int
2223
{
2324
$crap = (float) pow($complexity, 2) * pow(1.0 - $coverage, 3) + (float) $complexity;
2425

25-
return (int) $crap;
26+
return (int) round($crap);
2627
}
2728
}

tests/Functional/data/ScriptTest/no-color-success-red.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CLASS: App\Purchase\Fixer
22
+---------------------------+--------+--------+-----+------+
33
| METHOD | lcov | bcov | ccn | crap |
44
+---------------------------+--------+--------+-----+------+
5-
| CLASS | 62.36 | 54.53 | 12 | 19 |
5+
| CLASS | 62.36 | 54.53 | 12 | 20 |
66
| fix | 86.12 | 73.74 | 2 | 2 |
77
| fixCharges | 100.00 | 100.00 | 4 | 4 |
88
| fixPrice | 0.00 | 0.00 | 6 | 42 |

tests/Functional/data/ScriptTest/success-red.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+---------------------------+--------+--------+-----+------+
33
| METHOD | lcov | bcov | ccn | crap |
44
+---------------------------+--------+--------+-----+------+
5-
| CLASS | 62.36 | 54.53 | 12 | 19 |
5+
| CLASS | 62.36 | 54.53 | 12 | 20 |
66
| fix | 86.12 | 73.74 | 2 | 2 |
77
| fixCharges | 100.00 | 100.00 | 4 | 4 |
88
| fixPrice | 0.00 | 0.00 | 6 | 42 |

0 commit comments

Comments
 (0)