Skip to content

Commit d286378

Browse files
committed
fix branch coverage calculation
1 parent 79de1ef commit d286378

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/coverlet.core/CoverageSummary.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,18 @@ public double CalculateLineCoverage(KeyValuePair<string, Documents> module)
5252

5353
public double CalculateBranchCoverage(KeyValuePair<string, Lines> method)
5454
{
55-
double coverage = 0, totalLines = 0, linesCovered = 0;
55+
double coverage = 0, totalPoints = 0, pointsCovered = 0;
5656
foreach (var line in method.Value)
5757
{
58-
totalLines++;
59-
if (line.Value.Hits > 0 && line.Value.IsBranchPoint)
60-
linesCovered++;
58+
if (line.Value.IsBranchPoint)
59+
{
60+
totalPoints++;
61+
if (line.Value.Hits > 0)
62+
pointsCovered++;
63+
}
6164
}
6265

63-
coverage = totalLines == 0 ? totalLines : linesCovered / totalLines;
66+
coverage = totalPoints == 0 ? totalPoints : pointsCovered / totalPoints;
6467
return Math.Round(coverage, 3);
6568
}
6669

0 commit comments

Comments
 (0)