apply method

(List<AuditRunResult>, int) apply(
  1. List<AuditRunResult> results,
  2. ProjectContext context
)

Returns a copy of results with every suppressed issue removed, along with how many issues were suppressed in total. An audit whose findings are all suppressed is still reported (with an empty issue list), so it shows up as passed rather than silently disappearing.

Implementation

(List<AuditRunResult> filtered, int suppressedCount) apply(
  List<AuditRunResult> results,
  ProjectContext context,
) {
  if (isEmpty) {
    return (results, 0);
  }

  var suppressed = 0;
  final filtered = <AuditRunResult>[];

  for (final run in results) {
    final keptIssues = <SecurityIssue>[];

    for (final issue in run.result.issues) {
      if (_matches(run.audit.id, issue, context)) {
        suppressed++;
      } else {
        keptIssues.add(issue);
      }
    }

    filtered.add(
      AuditRunResult(
        audit: run.audit,
        result: AuditResult(issues: keptIssues),
      ),
    );
  }

  return (filtered, suppressed);
}