Skip to content

Commit

Permalink
proposed fix of issue coverlet-coverage#1679
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk committed Sep 4, 2024
1 parent a3e16fd commit e44e65b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public CoveragePrepareResult PrepareModules()
_parameters.IncludeFilters = _parameters.IncludeFilters?.Where(f => _instrumentationHelper.IsValidFilterExpression(f)).ToArray();

IReadOnlyList<string> validModules = _instrumentationHelper.SelectModules(modules, _parameters.IncludeFilters, _parameters.ExcludeFilters).ToList();
foreach (var excludedModule in modules.Except(validModules))
foreach (string excludedModule in modules.Except(validModules))
{
_logger.LogVerbose($"Excluded module: '{excludedModule}'");
}
Expand Down Expand Up @@ -365,16 +365,6 @@ private void CalculateCoverage()
{
foreach (InstrumenterResult result in _results)
{
if (!_fileSystem.Exists(result.HitsFilePath))
{
// Hits file could be missed mainly for two reason
// 1) Issue during module Unload()
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
// module tracker is never used
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
continue;
}

var documents = result.Documents.Values.ToList();
if (_parameters.UseSourceLink && result.SourceLink != null)
{
Expand All @@ -386,6 +376,16 @@ private void CalculateCoverage()
}
}

if (!_fileSystem.Exists(result.HitsFilePath))
{
// Hits file could be missed mainly for two reason
// 1) Issue during module Unload()
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
// module tracker is never used
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
continue;
}

// Calculate lines to skip for every hits start/end candidate
// Nested ranges win on outermost one
foreach (HitCandidate hitCandidate in result.HitCandidates)
Expand Down

0 comments on commit e44e65b

Please sign in to comment.