DiagnosticSuppression.h header
#include <ew/app/DiagnosticSuppression.h>
Namespace ew::app
DiagnosticSuppression class
class ew::app::DiagnosticSuppression
The findings a project has chosen not to be told about again.
One store, consulted by every surface. Its predecessor was StyleSuppression, which knew about style categories and phrases and nothing else – so a writer could silence a crutch word and could not silence a timeline conflict at all, and "ignore this" meant something different depending on which panel they said it in. This is keyed on the two things every finding has: the rule that produced it, and its Diagnostic::fingerprint.
Three granularities, deliberately:
- A whole rule – "stop telling me about passive voice". Cheap, broad, and the right answer when a writer disagrees with the advice rather than with one instance of it.
- A phrase within a rule – "I use 'very' on purpose". Project-wide and independent of where the words appear, which is what a writer defending a habit actually means.
- One finding – "this particular repetition, in this chapter, is deliberate". Keyed on the fingerprint, which is built from the rule, the objects and the anchor's stable half, so it survives an unrelated edit to the same object. Suppressing by position would mean the finding came back the moment the author typed a word above it, which teaches writers to stop suppressing anything.
Members
void ew::app::diagnostics::DiagnosticSuppression::ignoreRule(const QString &ruleId)
Silences every finding from ruleId.
void ew::app::diagnostics::DiagnosticSuppression::ignoreRuleInCategory(const QString &ruleId, const QString &categoryId)
Silences ruleId's findings about objects in categoryId only.
Between the whole-rule hammer and the one-finding tweezers: "every Item is allowed to have no price" is a decision about a category, and without this it had to be made three hundred times or not at all.
void ew::app::diagnostics::DiagnosticSuppression::allowRuleInCategory(QStringView ruleId, QStringView categoryId)
Stops silencing ruleId inside categoryId.
bool ew::app::diagnostics::DiagnosticSuppression::ruleIgnoredInCategory(QStringView ruleId, QStringView categoryId) const
Whether ruleId is silenced inside categoryId.
const std::set< std::pair< QString, QString > > & ew::app::diagnostics::DiagnosticSuppression::ignoredRuleCategories() const
Every (rule id, category id) pair silenced.
void ew::app::diagnostics::DiagnosticSuppression::allowRule(QStringView ruleId)
Stops silencing ruleId, so its findings are reported again.
bool ew::app::diagnostics::DiagnosticSuppression::ruleIgnored(QStringView ruleId) const
Whether every finding from ruleId is silenced.
void ew::app::diagnostics::DiagnosticSuppression::ignorePhrase(const QString &ruleId, const QString &phrase)
Silences phrase wherever ruleId flags it, project-wide. Trimmed and folded to lower case, so the same habit defended once is defended however it is capitalised. An empty phrase is ignored (there is nothing to match).
void ew::app::diagnostics::DiagnosticSuppression::allowPhrase(QStringView ruleId, const QString &phrase)
Stops silencing phrase under ruleId.
bool ew::app::diagnostics::DiagnosticSuppression::phraseIgnored(QStringView ruleId, QStringView phrase) const
Whether phrase is silenced under ruleId.
void ew::app::diagnostics::DiagnosticSuppression::ignoreFinding(const QString &fingerprint)
Silences the one finding identified by fingerprint. An empty fingerprint is ignored – there is nothing to key on, and storing it would silence every finding that had not computed one.
void ew::app::diagnostics::DiagnosticSuppression::ignoreFinding(const QString &fingerprint, const SuppressionNote ¬e)
Silences one finding and records WHY.
Refused when note has no reason: an unexplained suppression is the one this whole record exists to prevent. ignoreFinding without a note remains for the paths that have no person to ask – an import, a grandfathering sweep – and those write their own reason.
SuppressionNote ew::app::diagnostics::DiagnosticSuppression::noteFor(QStringView fingerprint) const
Why fingerprint was silenced, or an empty note when nothing was recorded.
const std::map< QString, SuppressionNote > & ew::app::diagnostics::DiagnosticSuppression::notes() const
Every note, by fingerprint, so an audit panel can list who silenced what and why.
bool ew::app::diagnostics::DiagnosticSuppression::lapsed(QStringView fingerprint, QDate today) const
Whether fingerprint's suppression has lapsed as of today.
void ew::app::diagnostics::DiagnosticSuppression::allowFinding(QStringView fingerprint)
Stops silencing the finding identified by fingerprint.
bool ew::app::diagnostics::DiagnosticSuppression::findingIgnored(QStringView fingerprint) const
Whether the one finding identified by fingerprint is silenced.
bool ew::app::diagnostics::DiagnosticSuppression::suppresses(const Diagnostic &diagnostic, QDate today={}, const std::set< QString > &categoryIds={}) const
The single filter every surface calls. True when diagnostic's rule is silenced wholesale, its flagged phrase is silenced under that rule, or this exact finding has been silenced. today lapses any suppression whose expiry has passed; an invalid date means never lapse, which is what a caller with no clock wants. categoryIds are the categories the diagnostic's subject belongs to, for the per-category form.
const std::set< QString > & ew::app::diagnostics::DiagnosticSuppression::ignoredFindings() const
Every fingerprint silenced individually, so a suppression audit can list them.
const std::set< QString > & ew::app::diagnostics::DiagnosticSuppression::ignoredRules() const
Every rule silenced wholesale.
const std::set< std::pair< QString, QString > > & ew::app::diagnostics::DiagnosticSuppression::ignoredPhrases() const
Every (rule, phrase) pair silenced project-wide.
bool ew::app::diagnostics::DiagnosticSuppression::empty() const
True when nothing is silenced.
void ew::app::diagnostics::DiagnosticSuppression::clear()
Forgets every suppression.
QString ew::app::diagnostics::DiagnosticSuppression::serialize() const
A stable, human-diffable text form, one entry per line: "rule<TAB>id", "phrase<TAB>id<TAB>phrase" or "finding<TAB>fingerprint". deserialize is its inverse.
bool ew::app::diagnostics::DiagnosticSuppression::operator==(const DiagnosticSuppression &) const =default
Two suppression sets are equal when they silence exactly the same rules and findings.
static DiagnosticSuppression ew::app::diagnostics::DiagnosticSuppression::deserialize(const QString &text)
Parses the text produced by serialize; unrecognized or malformed lines are skipped.
SuppressionNote struct
struct ew::app::SuppressionNote
Why one finding was silenced, by whom, when, and when it lapses.
A reason is required, not offered. A silenced finding with no reason is indistinguishable from a mistake six months later – the writer cannot tell whether they decided this was fine or clicked the wrong button, so they either restore all of them or trust none of them. Static analysis tooling settled this argument decades ago: a suppression without a justification is itself a defect.
Members
QString ew::app::diagnostics::SuppressionNote::reason
Why, in the writer's own words. Never empty for a per-finding suppression.
QString ew::app::diagnostics::SuppressionNote::who
Who silenced it, so a shared project can tell.
QDate ew::app::diagnostics::SuppressionNote::when
When it was silenced.
QDate ew::app::diagnostics::SuppressionNote::until
The day it stops applying, or an invalid date for never.
A DATE rather than a named milestone because a date is unambiguous and needs no second concept to keep in step: "I will look at this again before the December draft" is a date the writer already has in mind, and the audit panel shows it lapsing.
bool operator==(const SuppressionNote &, const SuppressionNote &)=default
Two notes are equal when every field matches.