Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
daveMueller committed Mar 23, 2021
1 parent 799794e commit 371cbba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/coverlet.core/CoverageDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ internal class CoverageDetails
{
private double _averageModulePercent;

public Modules Modules { get; internal set; }
public int ModulesCount { get; internal set; }
public double Covered { get; internal set; }
public int Total { get; internal set; }
public double Percent
{
get
{
if (Modules?.Count == 0) return 0;
if (ModulesCount == 0) return 0;
return Total == 0 ? 100D : Math.Floor((Covered / Total) * 10000) / 100;
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/coverlet.core/CoverageSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public CoverageDetails CalculateLineCoverage(Documents documents)

public CoverageDetails CalculateLineCoverage(Modules modules)
{
var details = new CoverageDetails{Modules = modules};
var accumPercent = 0.0D;

if (modules.Count == 0)
var details = new CoverageDetails{ModulesCount = modules.Count};
if (details.ModulesCount == 0)
return details;

var accumPercent = 0.0D;

foreach (var module in modules)
{
var moduleCoverage = CalculateLineCoverage(module.Value);
Expand Down Expand Up @@ -155,12 +155,12 @@ public CoverageDetails CalculateBranchCoverage(Documents documents)

public CoverageDetails CalculateBranchCoverage(Modules modules)
{
var details = new CoverageDetails{ Modules = modules };
var accumPercent = 0.0D;

if (modules.Count == 0)
var details = new CoverageDetails { ModulesCount = modules.Count };
if (details.ModulesCount == 0)
return details;

var accumPercent = 0.0D;

foreach (var module in modules)
{
var moduleCoverage = CalculateBranchCoverage(module.Value);
Expand Down Expand Up @@ -219,12 +219,12 @@ public CoverageDetails CalculateMethodCoverage(Documents documents)

public CoverageDetails CalculateMethodCoverage(Modules modules)
{
var details = new CoverageDetails{ Modules = modules };
var accumPercent = 0.0D;

if (modules.Count == 0)
var details = new CoverageDetails { ModulesCount = modules.Count };
if (details.ModulesCount == 0)
return details;

var accumPercent = 0.0D;

foreach (var module in modules)
{
var moduleCoverage = CalculateMethodCoverage(module.Value);
Expand Down

0 comments on commit 371cbba

Please sign in to comment.