Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion FineCodeCoverageTests/AppOptionsProvider_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public void Should_Not_Default_Any_Other_AppOptions_Properties()
nameof(IAppOptions.ShowCoveredInOverviewMargin),
nameof(IAppOptions.ShowUncoveredInOverviewMargin),
nameof(IAppOptions.ShowPartiallyCoveredInOverviewMargin),
nameof(IAppOptions.ShowToolWindowToolbar)
nameof(IAppOptions.ShowToolWindowToolbar),
nameof(IAppOptions.Hide0Coverable)
};
CollectionAssert.AreEquivalent(expectedSetters.Select(s => $"set_{s}"), invocationNames);
}
Expand Down Expand Up @@ -278,6 +279,8 @@ internal void Should_Use_Deseralized_String_From_Store_For_AppOption_Property(Fu
{ nameof(IAppOptions.FunctionsExclude), new string[]{ "FunctionsExclude" } },
{ nameof(IAppOptions.FunctionsInclude), new string[]{ "FunctionsInclude" } },
{ nameof(IAppOptions.HideFullyCovered), true },
{ nameof(IAppOptions.Hide0Coverable),true },
{ nameof(IAppOptions.Hide0Coverage),true },
{ nameof(IAppOptions.Include), new string[]{ "Include" } },
{ nameof(IAppOptions.IncludeReferencedProjects),true},
{ nameof(IAppOptions.IncludeTestAssembly),true},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,7 @@ internal class TestCoverageProjectOptions : IAppOptions
public bool ShowUncoveredInOverviewMargin { get; set; }
public bool ShowPartiallyCoveredInOverviewMargin { get; set; }
public bool ShowToolWindowToolbar { get; set; }
public bool Hide0Coverable { get; set; }
public bool Hide0Coverage { get; set; }
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ ThresholdForCyclomaticComplexity When [cyclomatic complexity](https://en.wik
StickyCoverageTable Set to true for coverage table to have a sticky thead.
NamespacedClasses Set to false to show classes in report in short form. Affects grouping.
HideFullyCovered Set to true to hide classes, namespaces and assemblies that are fully covered.
Hide0Coverage Set to true to hide classes, namespaces and assemblies that have 0% coverage.
Hide0Coverable Set to false to show classes, namespaces and assemblies that are not coverable.

Enabled Specifies whether or not coverage output is enabled
RunWhenTestsFail By default coverage runs when tests fail. Set to false to prevent this. **Cannot be used in conjunction with RunInParallel**
Expand Down
54 changes: 51 additions & 3 deletions SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,12 @@ private string HideGroupingCss()

private string ObserveAndHideFullyCovered()
{
if (!appOptionsProvider.Get().HideFullyCovered)
var appOptions = appOptionsProvider.Get();
if (!(appOptions.HideFullyCovered | appOptions.Hide0Coverage | appOptions.Hide0Coverable))
{
return "";
}
return @"
var old = @"
var targetNode = document;//document.querySelector('table.overview.table-fixed.stripped');

var config = { attributes: false, childList: true, subtree: true };
Expand Down Expand Up @@ -883,7 +884,54 @@ private string ObserveAndHideFullyCovered()
var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
";
}
var code = $@"
function getCellValue(row, index){{
return parseInt(row.cells[index].innerText);
}}
var targetNode = document;

var config = {{ attributes: false, childList: true, subtree: true }};

var callback = function(mutationsList, observer) {{
var rows = document.querySelectorAll(""coverage-info table tbody tr"");
for(var i=0;i<rows.length;i++){{
var row = rows[i];
let hide = false;

const coverable = getCellValue(row,3);
const covered = getCellValue(row,1)
if(coverable === 0){{
if({appOptions.Hide0Coverable.ToString().ToLower()}){{
hide = true;
}}
}} else if(covered === 0){{
if({appOptions.Hide0Coverage.ToString().ToLower()}){{
hide = true;
}}
}} else if(covered === coverable){{

const branchCovered = getCellValue(row,7);
const branchTotal = getCellValue(row,8);

if(branchTotal === branchCovered){{
if({appOptions.HideFullyCovered.ToString().ToLower()}){{
hide = true;
}}
}}
}}

if(hide){{
row.style.display = ""none"";
}}

}};
}};

var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
";
return code;
}

private string HackGroupingToAllowAll(int groupingLevel)
{
Expand Down
8 changes: 8 additions & 0 deletions SharedProject/Options/AppOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ You can also ignore additional attributes by adding to this list (short name or
[Category(commonReportCategory)]
[Description("Set to true to hide classes, namespaces and assemblies that are fully covered.")]
public bool HideFullyCovered { get; set; }

[Category(commonReportCategory)]
[Description("Set to false to show classes, namespaces and assemblies that are not coverable.")]
public bool Hide0Coverable { get; set; }

[Category(commonReportCategory)]
[Description("Set to true to hide classes, namespaces and assemblies that have 0% coverage.")]
public bool Hide0Coverage { get; set; }
#endregion

#region OpenCover report category
Expand Down
4 changes: 4 additions & 0 deletions SharedProject/Options/AppOptionsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private void AddDefaults(IAppOptions appOptions)
appOptions.ShowCoveredInOverviewMargin = true;
appOptions.ShowPartiallyCoveredInOverviewMargin = true;
appOptions.ShowUncoveredInOverviewMargin = true;
appOptions.Hide0Coverable = true;
}

public void LoadSettingsFromStorage(IAppOptions instance)
Expand Down Expand Up @@ -179,6 +180,9 @@ internal class AppOptions : IAppOptions

public bool HideFullyCovered { get; set; }

public bool Hide0Coverable { get; set; }
public bool Hide0Coverage { get; set; }

public bool AdjacentBuildOutput { get; set; }

public RunMsCodeCoverage RunMsCodeCoverage { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions SharedProject/Options/IAppOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ internal interface IAppOptions : IMsCodeCoverageOptions, IFCCCommonOptions
bool StickyCoverageTable { get; set; }
bool NamespacedClasses { get; set; }
bool HideFullyCovered { get; set; }
bool Hide0Coverable { get; set; }
bool Hide0Coverage { get; set; }
bool AdjacentBuildOutput { get; set; }
RunMsCodeCoverage RunMsCodeCoverage { get; set; }
bool ShowToolWindowToolbar { get; set; }
Expand Down