Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: MATLAB compatibility #53

Merged
merged 1 commit into from Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/CodeCoverageSummary/Program.cs
Expand Up @@ -188,21 +188,19 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary

if (branchR.Any())
{
summary.BranchRate += double.Parse(branchR.First().Value);
summary.BranchRate += double.TryParse(branchR.First().Value, out double bRate) ? bRate : 0;

var branchesCovered = from item in coverage.Attributes()
where item.Name == "branches-covered"
select item;

if (branchesCovered.Any())
summary.BranchesCovered += int.Parse(branchesCovered.First().Value);
summary.BranchesCovered += int.TryParse(branchesCovered?.First().Value ?? "0", out int bCovered) ? bCovered : 0;

var branchesValid = from item in coverage.Attributes()
where item.Name == "branches-valid"
select item;

if (branchesValid.Any())
summary.BranchesValid += int.Parse(branchesValid.First().Value);
summary.BranchesValid += int.TryParse(branchesValid?.First().Value ?? "0", out int bValid) ? bValid : 0;
}

// test coverage for individual packages
Expand All @@ -219,8 +217,8 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary
{
Name = string.IsNullOrWhiteSpace(item.Attribute("name")?.Value) ? $"{Path.GetFileNameWithoutExtension(filename)} Package {i}" : item.Attribute("name").Value,
LineRate = double.Parse(item.Attribute("line-rate")?.Value ?? "0"),
BranchRate = double.Parse(item.Attribute("branch-rate")?.Value ?? "0"),
Complexity = double.Parse(item.Attribute("complexity")?.Value ?? "0")
BranchRate = double.TryParse(item.Attribute("branch-rate")?.Value ?? "0", out double bRate) ? bRate : 0,
Complexity = double.TryParse(item.Attribute("complexity")?.Value ?? "0", out double complex) ? complex : 0
};
summary.Packages.Add(packageCoverage);
summary.Complexity += packageCoverage.Complexity;
Expand Down