Skip to content

Commit

Permalink
hidden count fix to report
Browse files Browse the repository at this point in the history
  • Loading branch information
drjoho committed Mar 27, 2024
1 parent 746be7f commit 44c5351
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
limitations under the License.
*****************************************************************************/

import { getBGController, TabChangeType } from "../background/backgroundController";
import { IBasicTableRowRecord, IIssue, IMessage, IReport, IStoredReportMeta } from "../interfaces/interfaces";
import { getBGController, issueBaselineMatch, TabChangeType } from "../background/backgroundController";
import { IBasicTableRowRecord, IIssue, IMessage, IReport, IStoredReportMeta, UIIssue } from "../interfaces/interfaces";
import { CommonMessaging } from "../messaging/commonMessaging";
import { Controller, eControllerType, ListenerType } from "../messaging/controller";
import Config from "../util/config";
Expand Down Expand Up @@ -212,18 +212,20 @@ export class DevtoolsController extends Controller {
}
}

async getCountsWithHidden (reportCounts: IReport["counts"], ignored: IIssue[]) {
async getCountsWithHidden (reportCounts: IReport["counts"], issues:UIIssue[], ignored: IIssue[]) {
let counts = this.initCount(); // setup counts
// populate initial counts
counts.Violation = reportCounts.Violation;
counts["Needs review"] = reportCounts["Needs review"];
counts.Recommendation = reportCounts.Recommendation;
counts.Hidden = ignored.length;
counts.Hidden = 0;
counts.Pass = reportCounts.Pass;

// correct issue type counts to take into account the hidden issues
if (ignored.length > 0) { // if we have hidden
for (const ignoredIssue of ignored) {
if (!issues.some(issue => issueBaselineMatch(issue, ignoredIssue))) continue;
counts.Hidden++;
if ("Violation" === this.valueMap[ignoredIssue.value[0]][ignoredIssue.value[1]]) {
counts.Violation--;
}
Expand All @@ -250,7 +252,7 @@ export class DevtoolsController extends Controller {
let tabId = getTabId();
let tabInfo = await bgController.getTabInfo(tabId);
let ignored: IIssue[] = await bgController.getIgnore(tabInfo.url!);
let newCounts = await this.getCountsWithHidden(report.counts, ignored);
let newCounts = await this.getCountsWithHidden(report.counts, report.results, ignored);
const now = new Date().getTime();
devtoolsState!.lastReportMeta = {
id: devtoolsState!.storedReports.length+"",
Expand Down

0 comments on commit 44c5351

Please sign in to comment.