Skip to main content

Severity

Enum Severity 

Source
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 presentExit code
Error or Fix1 (EX_DIAG_ERROR)
Warn only2 (EX_DIAG_WARN)
Info / Suggest only, none0 (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:

  1. Explicit emission: a rule constructs the diagnostic with Severity::Suggest directly. S004 rel-to-trigraph-suggest is the first such rule.
  2. Engine rewrite: any diagnostic whose attached FixProposal has confidence.combined() < confidence_threshold is rewritten to Severity::Suggest by the engine in lint. 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

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for Severity

Source§

fn clone(&self) -> Severity

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Severity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Severity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Severity

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Severity

Source§

fn cmp(&self, other: &Severity) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Severity

Source§

fn eq(&self, other: &Severity) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Severity

Source§

fn partial_cmp(&self, other: &Severity) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Severity

Source§

impl Eq for Severity

Source§

impl StructuralPartialEq for Severity

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.