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

Commit e0feaaa

Browse files
authored
Merge pull request #6 from codacy/luis-ferreira/fix/overflow
Fix OverflowException when reporting coverage
2 parents 5fa9632 + d9c3f36 commit e0feaaa

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
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

src/Parsing/Processors/DotCoverProcessor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public Report Parse(string file)
2626
modules.Elements("File"))
2727
};
2828

29+
if (report.FilesList.Count == 0) {
30+
Console.WriteLine ("Warning: Got a report without File elements. Consider report dotCover with --ReportType=DetailedXML");
31+
}
32+
2933
foreach (var module in namespaces)
3034
{
3135
var classes = module.Elements("Type");

test/CSharpCoverage.Tests/packages.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@
875875
"xunit.extensibility.core": "[2.4.1]"
876876
}
877877
},
878-
"codacy.csharpcoverage": {
878+
"Codacy.CSharpCoverage": {
879879
"type": "Project",
880880
"dependencies": {
881881
"CommandLineParser": "2.5.0",

0 commit comments

Comments
 (0)