pub enum Severity {
Off,
Suggest,
Info,
Warn,
Error,
Fix,
}Expand description
Rule severity level. Configurable per rule in .marque.toml.
§Ordering
The derived Ord is Off < Suggest < Info < Warn < Error < Fix.
The ordering is exposed for consumers that want to compare
severities (e.g., “is this at least Error?”) but the config
loader does not use it as a merge operator today. Suggest
sits between Off and Info because it is the lightest
firing-but-non-actionable channel — quieter than Info (which
has no candidate replacement attached) and louder than Off
(which is non-firing entirely).
§Exit-code semantics
marque check maps severities to exit codes as follows:
| Severity counts present | Exit code |
|---|---|
Error or Fix | 1 (EX_DIAG_ERROR) |
Warn only | 2 (EX_DIAG_WARN) |
Info / Suggest only, none | 0 (EX_OK) |
Info and Suggest are the only severities whose diagnostics are
emitted and keep the exit code at zero. Warn still fails CI
via EX_DIAG_WARN. The tonal distinction is advisory: Warn
means “this might be wrong”; Info means “FYI, probably
intentional but worth surfacing”; Suggest means “I have a
candidate replacement but I’m not confident enough to auto-apply
it — eyes on it.” Rules like W034 sci-custom-control-info
(which reports unpublished SCI control systems — legitimate per
CAPCO but rare) are natural Info candidates; rules like S004 rel-to-trigraph-suggest (which proposes a higher-prior trigraph
alternative for an ambiguous REL TO entry) emit at Suggest.
§Suggest channel semantics
Suggest is the firing-but-non-applying channel: a diagnostic
emitted at Suggest carries a candidate FixProposal that the
engine will never auto-apply, regardless of confidence. The
fix is informational — it tells the user what the rule would
suggest if confidence were higher. Two paths produce
Suggest-severity diagnostics:
- Explicit emission: a rule constructs the diagnostic with
Severity::Suggestdirectly.S004 rel-to-trigraph-suggestis the first such rule. - Engine rewrite: any diagnostic whose attached
FixProposalhasconfidence.combined() < confidence_thresholdis rewritten toSeverity::Suggestby the engine inlint. This subsumes the prior silent-drop behavior at threshold-gate time so below-threshold proposals stay observable.
In both cases, Engine::fix filters out Suggest diagnostics
from auto-apply by construction. Suggest diagnostics with
fix: None are also valid (informational suggestion with no
candidate replacement — used by future rules like #206’s
REL TO opaque-uncertain reduction, where the rule has signal
to surface but no specific replacement to propose); the
renderer handles the missing-fix case cleanly.
§Merge semantics (current: last-write-wins)
marque-config merges layers in strict precedence order — env vars
override .marque.local.toml which overrides .marque.toml. Whatever
the highest-precedence layer says for a given rule wins, including
downgrades: a local override of "off" will suppress a project-config
"error". This is intentional — individual classifiers sometimes need
to silence a rule while iterating, and the audit log still records the
configured severity for every applied fix.
If a future policy requires strictness-only merging (where a lower
layer cannot downgrade a higher layer’s severity), change the loader
to .max() over Severity::parse_config values rather than extend.
The derived Ord above is already the correct operator for that case.
Variants§
Off
Rule is disabled entirely. FR-008: severity=off is unrepresentable on emitted diagnostics
— a rule at Off never fires, so no Diagnostic is produced.
Suggest
Advisory channel — diagnostic carries a candidate fix that will not auto-apply.
Distinct from Info (FYI, no actionable replacement) and
from Off (non-firing). The fix-bearing diagnostic remains
visible in lint output but the engine excludes it from
auto-apply regardless of confidence. This is the
suggest-don’t-fix channel: rules with low-confidence
candidate corrections (e.g., S004 rel-to-trigraph-suggest)
can surface “did you mean?” hints without committing to the
rewrite.
Suggest keeps the CLI exit code at 0 (same as Info),
so it is CI-silent.
Info
Emit informational diagnostic; does not block check-mode exit
code. Intended for “audit-visible but probably intentional”
signals — cases where the marking may be correct but the user
may want to verify (e.g., unpublished SCI control systems).
Warn
Emit warning; non-error, but still non-zero in check mode
(produces EX_DIAG_WARN = 2). Different from Info in tone
and exit-code impact: Warn is “this might be wrong” and
CI-visible; Info is “FYI, probably intentional but worth
surfacing” and CI-silent (exit 0).
Error
Emit error; blocks --check exit code.
Fix
Apply fix automatically when --fix flag is present.
Implementations§
Source§impl Severity
impl Severity
Sourcepub fn parse_config(s: &str) -> Option<Self>
pub fn parse_config(s: &str) -> Option<Self>
Parse a severity level from a config string. Returns None for
unrecognized values; the config loader treats None as a hard error.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Canonical lowercase string form, suitable for JSON output.
This is the inverse of Severity::parse_config and is the stable
surface that JSON consumers should depend on — never format!("{:?}")
(which exposes Debug formatting as an unintended API).