applyAcks function
Fold state into result for project. Suppresses issues whose ack
still matches; surfaces (does not suppress) issues whose ack is stale,
recording the stale ids.
Implementation
AckOutcome applyAcks(
CheckResult result,
DialectProject project,
StateStore state,
) {
if (state.checks.isEmpty) {
return AckOutcome(result: result, suppressed: 0, staleAcks: const []);
}
final surviving = <Issue>[];
final staleAcks = <String>{};
var suppressed = 0;
for (final issue in result.issues) {
final id = ackId(issue);
final ack = id == null ? null : state.checks[id];
if (ack == null || !isAckableRule(issue.ruleName)) {
surviving.add(issue);
continue;
}
final current = ackFingerprint(
issue.ruleName,
issue.locale,
issue.key!,
project,
);
if (current != null && current == ack.acknowledged) {
suppressed++; // matches — hide it
} else {
surviving.add(issue); // drifted — show it again
staleAcks.add(id!);
}
}
return AckOutcome(
result: CheckResult(issues: surviving),
suppressed: suppressed,
staleAcks: staleAcks.toList()..sort(),
);
}