Module: Rigor::Configuration::SeverityProfile
- Defined in:
- lib/rigor/configuration/severity_profile.rb
Overview
ADR-8 § "Severity profile" — three named profiles tune the severity of every built-in
Analysis::CheckRules rule for the run. Profiles are applied as a final filter on
Diagnostic#severity: rules emit with their authored severity, then Analysis::Runner re-stamps the
severity from the active profile before adding the diagnostic to the result.
Three profiles:
lenient: Only proven (:no) diagnostics are errors; uncertain (:maybe) drop to:warning. Useful for incremental adoption on legacy code.balanced(default): Current Rigor stance — most rules:error;dump.type:info; uncertain rules:warning.strict: Every rule is:error. CI-friendly.
The profile resolution order:
- Profile-specific entry for the canonical rule id.
- The diagnostic's own authored severity (the rule's default).
:error(catch-all so an unrecognised rule still emits visibly — the public-API drift spec catches the bookkeeping gap separately).
Constant Summary collapse
- VALID_PROFILES =
%i[lenient balanced strict].freeze
- VALID_SEVERITIES =
%i[error warning info off].freeze
- DEFAULT_PROFILE =
:balanced- PROFILES =
Per-profile severity tables. Missing keys fall back to the diagnostic's authored severity (typically
:error). { lenient: { "call.undefined-method" => :error, "call.self-undefined-method" => :off, "call.unresolved-toplevel" => :off, "call.wrong-arity" => :error, "call.argument-type-mismatch" => :warning, "call.possible-nil-receiver" => :warning, "flow.always-raises" => :warning, "flow.unreachable-branch" => :info, "flow.dead-assignment" => :info, "flow.always-truthy-condition" => :info, "flow.unreachable-clause" => :info, "assert.type-mismatch" => :error, "dump.type" => :info, "def.return-type-mismatch" => :warning, "def.method-visibility-mismatch" => :warning, "def.override-visibility-reduced" => :off, "def.override-return-widened" => :off, "def.override-param-narrowed" => :off, "def.ivar-write-mismatch" => :warning, # Opt-in author assertion: you only see it if you wrote a # `conforms-to` directive, so it stays a :warning even in # lenient — it is never unsolicited noise. "rbs_extended.unsatisfied-conformance" => :warning }.freeze, balanced: { "call.undefined-method" => :error, "call.self-undefined-method" => :off, "call.unresolved-toplevel" => :warning, "call.wrong-arity" => :error, "call.argument-type-mismatch" => :error, "call.possible-nil-receiver" => :error, "flow.always-raises" => :error, "flow.unreachable-branch" => :warning, "flow.dead-assignment" => :warning, "flow.always-truthy-condition" => :warning, # ADR-47 WD4: stays :info (not :warning like its siblings) in the # default balanced profile until the regression-corpus FP gate is # green; promote to :warning once Mastodon/GitLab/Redmine triage # to zero net false positives. "flow.unreachable-clause" => :info, "assert.type-mismatch" => :error, "dump.type" => :info, "def.return-type-mismatch" => :warning, "def.method-visibility-mismatch" => :error, "def.override-visibility-reduced" => :warning, "def.override-return-widened" => :warning, "def.override-param-narrowed" => :warning, "def.ivar-write-mismatch" => :warning, "rbs_extended.unsatisfied-conformance" => :warning }.freeze, strict: { "call.undefined-method" => :error, "call.self-undefined-method" => :off, "call.unresolved-toplevel" => :error, "call.wrong-arity" => :error, "call.argument-type-mismatch" => :error, "call.possible-nil-receiver" => :error, "flow.always-raises" => :error, "flow.unreachable-branch" => :error, "flow.dead-assignment" => :error, "flow.always-truthy-condition" => :error, # ADR-47: strict opts into the new rule at :warning (one notch # below its :error siblings) while it proves out — see the # balanced-profile note above. "flow.unreachable-clause" => :warning, "assert.type-mismatch" => :error, "dump.type" => :error, "def.return-type-mismatch" => :error, "def.method-visibility-mismatch" => :error, "def.override-visibility-reduced" => :error, "def.override-return-widened" => :error, "def.override-param-narrowed" => :error, "def.ivar-write-mismatch" => :error, "rbs_extended.unsatisfied-conformance" => :error }.freeze }.freeze
Class Method Summary collapse
-
.resolve(rule:, authored_severity:, profile: DEFAULT_PROFILE, overrides: {}, bleeding_edge_overrides: {}) ⇒ Symbol
Resolves the configured severity for a diagnostic given the active profile and any per-rule overrides.
Class Method Details
.resolve(rule:, authored_severity:, profile: DEFAULT_PROFILE, overrides: {}, bleeding_edge_overrides: {}) ⇒ Symbol
Resolves the configured severity for a diagnostic given the active profile and any per-rule overrides.
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rigor/configuration/severity_profile.rb', line 130 def resolve(rule:, authored_severity:, profile: DEFAULT_PROFILE, overrides: {}, bleeding_edge_overrides: {}) return if rule.nil? override = overrides[rule] || family_override(rule, overrides) return override.to_sym if override bleeding = bleeding_edge_overrides[rule] return bleeding.to_sym if bleeding profile_table = PROFILES[profile] || PROFILES.fetch(DEFAULT_PROFILE) profile_table.fetch(rule, ) end |