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, "call.raise-non-exception" => :warning, "flow.always-raises" => :warning, "flow.unreachable-branch" => :info, "flow.dead-assignment" => :info, "flow.always-truthy-condition" => :info, "flow.unreachable-clause" => :info, "flow.duplicate-hash-key" => :info, "flow.return-in-ensure" => :info, "flow.shadowed-rescue-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, # ADR-8 companion (PHPStan IgnoreParseErrorRule-modelled): a broken suppression comment is # equally bad in every profile — it silently fails to do what the author believes it does — so # both rules stay :warning across all three profiles (including strict). "suppression.unknown-rule" => :warning, "suppression.empty" => :warning, "suppression.unknown-marker" => :warning, # ADR-100 — a new required diagnostic (ADR-50 WD1), so it is `:off` in every shipped profile and # reaches a user only through the `use-of-void-value` bleeding-edge feature, which overrides this # to `:warning`. "static.value-use.void" => :off, # 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, "call.raise-non-exception" => :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, "flow.duplicate-hash-key" => :warning, "flow.return-in-ensure" => :warning, "flow.shadowed-rescue-clause" => :warning, "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, "suppression.unknown-rule" => :warning, "suppression.empty" => :warning, "suppression.unknown-marker" => :warning, "static.value-use.void" => :off, "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, "call.raise-non-exception" => :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, "flow.duplicate-hash-key" => :error, "flow.return-in-ensure" => :error, "flow.shadowed-rescue-clause" => :error, "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, "suppression.unknown-rule" => :warning, "suppression.empty" => :warning, "suppression.unknown-marker" => :warning, # `:off` even under strict: the gate is `bleeding_edge:`, not the profile (ADR-50 WD1 / ADR-100). "static.value-use.void" => :off, "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.
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/rigor/configuration/severity_profile.rb', line 161 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 |