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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ ThresholdForCrapScore When [crap score](https://testing.googleblog.

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.

RunSettingsOnly Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings
CoverletCollectorDirectoryPath Specify path to directory containing coverlet collector files if you need functionality that the FCC version does not provide.
Expand Down
57 changes: 57 additions & 0 deletions SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,62 @@ private string HideGroupingCss()
";
}

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

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

var callback = function(mutationsList, observer) {
var fullyCoveredTds = document.querySelectorAll('td.covered100.green')

for (var i = 0; i < fullyCoveredTds.length; i++)
{
var td = fullyCoveredTds[i];
var parent = td.parentNode;
if (parent.nodeName === 'TABLE')
{
parent = parent.parentNode;
if (parent.nodeName === 'COVERAGE-BAR')
{
parent = parent.parentNode;
if (parent.nodeName === 'TD' || parent.nodeName === 'TH')
{
parent = parent.parentNode;
var coverageBars = parent.querySelectorAll('td>coverage-bar');
if(coverageBars.length == 0){
coverageBars = parent.querySelectorAll('th>coverage-bar');
}
var shouldHide = true;
// currently there is no option to hide branch coverage.
if(coverageBars.length === 2){
var branchCoverageBar = coverageBars[1];
// includes gray
var td = branchCoverageBar.querySelector('table>td.covered100');
if(!td){
shouldHide = false;
}
}
if(shouldHide){
parent.style.setProperty('display', 'none');
}
}
}

}
}
};

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

private string HackGroupingToAllowAll(int groupingLevel)
{
return $@"
Expand Down Expand Up @@ -933,6 +989,7 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo
<script type=""text/javascript"">
{GetStickyTableHead()}
{HackGroupingToAllowAll(groupingLevel)}
{ObserveAndHideFullyCovered()}
function getRuleBySelector(cssRules,selector){{
for(var i=0;i<cssRules.length;i++){{
if(cssRules[i].selectorText == selector){{
Expand Down
4 changes: 4 additions & 0 deletions SharedProject/Options/AppOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ You can also ignore additional attributes by adding to this list (short name or
[Description("Set to false to show classes in report in short form.")]
public bool NamespacedClasses { get; set; } = true;

[Category(reportCategory)]
[Description("Set to true to hide classes, namespaces and assemblies that are fully covered.")]
public bool HideFullyCovered { get; set; }

[SuppressMessage("Usage", "VSTHRD010:Invoke single-threaded types on Main thread")]
public override void SaveSettingsToStorage()
{
Expand Down
1 change: 1 addition & 0 deletions SharedProject/Options/IAppOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public interface IAppOptions
bool CoverageColoursFromFontsAndColours { get; }
bool StickyCoverageTable { get; }
bool NamespacedClasses { get; }
bool HideFullyCovered { get; }
}
}