handle Complexity as an int or percentage #9

This commit is contained in:
irongut
2021-09-26 00:58:44 +01:00
parent 6db46e287e
commit 9b11daeca8
4 changed files with 1095 additions and 9 deletions
+37 -6
View File
@@ -141,7 +141,7 @@ namespace CodeCoverageSummary
Name = item.Attribute("name").Value,
LineRate = double.Parse(item.Attribute("line-rate")?.Value ?? "0"),
BranchRate = double.Parse(item.Attribute("branch-rate")?.Value ?? "0"),
Complexity = int.Parse(item.Attribute("complexity")?.Value ?? "0")
Complexity = double.Parse(item.Attribute("complexity")?.Value ?? "0")
};
summary.Packages.Add(packageCoverage);
summary.Complexity += packageCoverage.Complexity;
@@ -184,12 +184,27 @@ namespace CodeCoverageSummary
}
textOutput.AppendLine($"Line Rate = {summary.LineRate * 100:N0}%, Lines Covered = {summary.LinesCovered} / {summary.LinesValid}")
.AppendLine($"Branch Rate = {summary.BranchRate * 100:N0}%, Branches Covered = {summary.BranchesCovered} / {summary.BranchesValid}")
.AppendLine($"Complexity = {summary.Complexity}");
.AppendLine($"Branch Rate = {summary.BranchRate * 100:N0}%, Branches Covered = {summary.BranchesCovered} / {summary.BranchesValid}");
if (summary.Complexity % 1 == 0)
{
textOutput.AppendLine($"Complexity = {summary.Complexity}");
}
else
{
textOutput.AppendLine($"Complexity = {summary.Complexity * 100:N0}%");
}
foreach (CodeCoverage package in summary.Packages)
{
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity}");
if (package.Complexity % 1 == 0)
{
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity}");
}
else
{
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity * 100:N0}%");
}
}
return textOutput.ToString();
@@ -210,11 +225,27 @@ namespace CodeCoverageSummary
foreach (CodeCoverage package in summary.Packages)
{
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity}");
if (package.Complexity % 1 == 0)
{
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity}");
}
else
{
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity * 100:N0}%");
}
}
markdownOutput.Append($"**Summary** | **{summary.LineRate * 100:N0}%** ({summary.LinesCovered} / {summary.LinesValid}) | ")
.AppendLine($"**{summary.BranchRate * 100:N0}%** ({summary.BranchesCovered} / {summary.BranchesValid}) | {summary.Complexity}");
.Append($"**{summary.BranchRate * 100:N0}%** ({summary.BranchesCovered} / {summary.BranchesValid}) | ");
if (summary.Complexity % 1 == 0)
{
markdownOutput.AppendLine($"{summary.Complexity}");
}
else
{
markdownOutput.AppendLine($"{summary.Complexity * 100:N0}%");
}
return markdownOutput.ToString();
}