Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 92f18f6

Browse files
committed
fix: Safe check to avoid OverflowException
This checks the division by zero before converting into Int32. Signed-off-by: Luís Ferreira <[email protected]>
1 parent 5fa9632 commit 92f18f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Models/Result/CodacyReport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public CodacyReport(IEnumerable<FileInfo> fileReports)
2525
.Aggregate((Covered: 0, Total: 0),
2626
(t, n) => t = (Covered: t.Covered + n.Covered, Total: t.Total + n.Total));
2727

28-
Total = Convert.ToInt32(Math.Round((double) totalTuple.Covered / totalTuple.Total * 100));
28+
Total = Convert.ToInt32((totalTuple.Total == 0) ? 0.0 : Math.Round((double) totalTuple.Covered / totalTuple.Total * 100));
2929
FileReports = fileReports;
3030
}
3131

0 commit comments

Comments
 (0)