oct.linter.rule_registry module#
Purpose#
Provide a structured registry of all lint rules with human-readable
documentation for each rule: rationale, correct pattern, common mistake,
spec reference, and severity tier. Powers oct lint --explain <rule>
and the linter’s three-tier failure classification.
Responsibilities#
Define the
RuleInfodataclass that carries rule metadata.Populate
RULE_REGISTRYwith one entry per rule in_DEFAULT_RULES.Expose
get_rule_info()andlist_rules()for lookup / enumeration.Expose
get_severity()so the linter and quality gate can decide whether a finding blocks the build or is reported as advisory.
Diagnostics#
Domain: OCT-LINTER Levels:
L3 — rule registry queries
Contracts#
Every key in
_DEFAULT_RULESmust have a correspondingRuleInfo.RuleInfois frozen — registry is immutable after module load.severityis one of"blocking","advisory", or"info".blockingmeans a violation flips the run to non-zero exit;advisoryis reported but does not affect exit code;infois reserved for future low-priority hints.
Dependencies#
- class oct.linter.rule_registry.RuleInfo(name: str, label: str, rationale: str, correct_pattern: str, common_mistake: str, spec_reference: str, fixable: bool, profiles: list[str], severity: str = 'blocking', severity_per_profile: dict[str, str] = <factory>)[source]#
Bases:
objectImmutable documentation record for a single lint rule.
The
severityfield (FS-C4) classifies each rule’s failure mode:"blocking"(default) — a violation flips the linter exit code to 1 and the quality gate to non-zero."advisory"— a violation is reported in JSON output and logs but does not affect exit codes. AI agents and CI can use this tier to surface improvement opportunities without blocking merges."info"— reserved for low-priority hints (future use).
The
severity_per_profilemap allows a rule to beadvisoryat one profile andblockingat another (e.g.tests_existis advisory at compact, blocking at strict).- common_mistake: str#
- correct_pattern: str#
- fixable: bool#
- label: str#
- name: str#
- profiles: list[str]#
- rationale: str#
- severity: str = 'blocking'#
- severity_per_profile: dict[str, str]#
- spec_reference: str#
- oct.linter.rule_registry.get_rule_info(name: str) RuleInfo | None[source]#
Return the
RuleInfofor name, orNoneif unknown.
- oct.linter.rule_registry.get_severity(rule_name: str, profile: str = 'strict') str[source]#
Return the severity tier (
blocking/advisory/info) for rule_name under profile (FS-C4).Resolution order: profile-specific override → rule’s default severity →
"blocking"for unknown rules (fail-safe).