RuleRegistry.h header

#include <ew/app/RuleRegistry.h>

Namespace ew::app

RuleRegistry class

class ew::app::RuleRegistry

Every rule the product knows about, and whatever the project has said about them.

One list, whichever validator owns the check. The Conflicts dock filters by rule and by severity across timeline, branching and style at once, which it can only do because there is somewhere that knows all three – and a finding can name its rule in the author's language instead of a raw token because that somewhere holds the display name too.

A project may enable, disable or re-rank any rule. Those overrides are all this stores: the rule list itself is built from code, so a project file can never introduce a rule nothing evaluates, nor lose one by being older than the release that added it.

Members

static RuleRegistry ew::app::diagnostics::RuleRegistry::builtIn()

Every rule shipped with the product – the timeline's continuity checks, the branching module's structural checks, and the style engine's craft rules.

void ew::app::diagnostics::RuleRegistry::add(Rule rule)

Adds rule, replacing any rule already registered under the same id.

const std::vector< Rule > & ew::app::diagnostics::RuleRegistry::rules() const

Every registered rule, in registration order.

const Rule * ew::app::diagnostics::RuleRegistry::find(QStringView id) const

The rule with id, or null when none is registered.

QString ew::app::diagnostics::RuleRegistry::displayName(QStringView id) const

What to call id in a list. Falls back to the id itself for a rule the registry does not know, which is what a finding from a newer release looks like to an older one – an unfamiliar name reads better than a blank.

Severity ew::app::diagnostics::RuleRegistry::severityOf(QStringView id, Severity fallback) const

The severity findings from id should carry, or fallback when the rule is unknown.

bool ew::app::diagnostics::RuleRegistry::isEnabled(QStringView id) const

Whether id runs at all. An unknown rule is treated as enabled: a finding that already exists should be shown, not silently dropped because the registry has not heard of it.

void ew::app::diagnostics::RuleRegistry::setEnabled(QStringView id, bool enabled)

Turns id on or off. No effect when the rule is not registered.

void ew::app::diagnostics::RuleRegistry::setSeverity(QStringView id, Severity severity)

Re-ranks id. No effect when the rule is not registered.

QString ew::app::diagnostics::RuleRegistry::serializeOverrides() const

The project's overrides – and only those – in a stable, human-diffable text form, one "id<TAB>enabled<TAB>severity" per line.

Only what differs from the built-in defaults, so a project that has changed nothing stores nothing, and a release that re-ranks a rule takes effect for every project that never had an opinion about it.

void ew::app::diagnostics::RuleRegistry::applyOverrides(const QString &text)

Applies the overrides in text, as produced by serializeOverrides. Lines naming an unregistered rule are skipped rather than invented.

Functions

QString ew::app::diagnostics::qualifiedRuleId(QStringView validator, QStringView token)

The rule id a check produces, as "<validator>/<token>" – "timeline/two-places-at-once".

Composed rather than written out, so a validator's own token table stays the single source of truth for its checks and no second list can drift from it.