Skip to content

Commit 5cea760

Browse files
committed
#363: Fixed clover file handling (several branches per line)
1 parent bb325ba commit 5cea760

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/Readme.txt

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ For further details take a look at LICENSE.txt.
6363

6464
CHANGELOG
6565

66+
4.6.2.0
67+
68+
* Fix: #363: Fixed clover file handling (several branches per line)
69+
6670
4.6.1.0
6771

6872
* Fix: #351: Fixed reading large XML coverage files

src/ReportGenerator.Core/Parser/CloverParser.cs

+22-10
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,36 @@ private static Dictionary<int, ICollection<Branch>> GetBranches(IEnumerable<XEle
187187
int negativeBrancheCovered = int.Parse(line.Attribute("falsecount").Value, CultureInfo.InvariantCulture);
188188
int positiveBrancheCovered = int.Parse(line.Attribute("truecount").Value, CultureInfo.InvariantCulture);
189189

190-
var branches = new HashSet<Branch>();
190+
if (result.ContainsKey(lineNumber))
191+
{
192+
var branches = result[lineNumber];
193+
194+
Branch negativeBranch = branches.First();
195+
Branch positiveBranch = branches.ElementAt(1);
191196

192-
string identifier1 = string.Format(
197+
negativeBranch.BranchVisits = Math.Max(negativeBrancheCovered > 0 ? 1 : 0, negativeBranch.BranchVisits);
198+
positiveBranch.BranchVisits = Math.Max(positiveBrancheCovered > 0 ? 1 : 0, positiveBranch.BranchVisits);
199+
}
200+
else
201+
{
202+
string identifier1 = string.Format(
193203
CultureInfo.InvariantCulture,
194204
"{0}_{1}",
195205
lineNumber,
196206
"0");
197207

198-
string identifier2 = string.Format(
199-
CultureInfo.InvariantCulture,
200-
"{0}_{1}",
201-
lineNumber,
202-
"1");
208+
string identifier2 = string.Format(
209+
CultureInfo.InvariantCulture,
210+
"{0}_{1}",
211+
lineNumber,
212+
"1");
203213

204-
branches.Add(new Branch(negativeBrancheCovered > 0 ? 1 : 0, identifier1));
205-
branches.Add(new Branch(positiveBrancheCovered > 0 ? 1 : 0, identifier2));
214+
var branches = new HashSet<Branch>();
215+
branches.Add(new Branch(negativeBrancheCovered > 0 ? 1 : 0, identifier1));
216+
branches.Add(new Branch(positiveBrancheCovered > 0 ? 1 : 0, identifier2));
206217

207-
result.Add(lineNumber, branches);
218+
result.Add(lineNumber, branches);
219+
}
208220
}
209221

210222
return result;

0 commit comments

Comments
 (0)