oct
Loading...
Searching...
No Matches
oct.linter.rule_registry Namespace Reference

Classes

class  RuleInfo

Functions

RuleInfo|None get_rule_info (str name)
list[RuleInfo] list_rules ()
str get_severity (str rule_name, str profile="strict")
bool is_blocking (str rule_name, str profile="strict")

Variables

str SEVERITY_BLOCKING = "blocking"
str SEVERITY_ADVISORY = "advisory"
str SEVERITY_INFO = "info"
 _VALID_SEVERITIES = frozenset({SEVERITY_BLOCKING, SEVERITY_ADVISORY, SEVERITY_INFO})

Detailed Description

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 ``RuleInfo`` dataclass that carries rule metadata.
- Populate ``RULE_REGISTRY`` with one entry per rule in ``_DEFAULT_RULES``.
- Expose ``get_rule_info()`` and ``list_rules()`` for lookup / enumeration.
- Expose :func:`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:
    L2 - (none) module-load-time registry construction
    L3 - rule registry queries
    L4 - (none)

Contracts
---------
- Every key in ``_DEFAULT_RULES`` must have a corresponding ``RuleInfo``.
- ``RuleInfo`` is frozen - registry is immutable after module load.
- ``severity`` is one of ``"blocking"``, ``"advisory"``, or ``"info"``.
  ``blocking`` means a violation flips the run to non-zero exit;
  ``advisory`` is reported but does not affect exit code; ``info`` is
  reserved for future low-priority hints.

Dependencies
------------
- oct.core.diagnostics (_dbg structured logger)

Function Documentation

◆ get_rule_info()

RuleInfo | None oct.linter.rule_registry.get_rule_info ( str name)
Return the ``RuleInfo`` for *name*, or ``None`` if unknown.

Definition at line 482 of file rule_registry.py.

◆ get_severity()

str oct.linter.rule_registry.get_severity ( str rule_name,
str profile = "strict" )
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).

Definition at line 496 of file rule_registry.py.

Here is the caller graph for this function:

◆ is_blocking()

bool oct.linter.rule_registry.is_blocking ( str rule_name,
str profile = "strict" )
Convenience predicate: return True iff a violation of *rule_name*
should flip the linter / quality-gate exit code at *profile*.

Definition at line 513 of file rule_registry.py.

Here is the call graph for this function:

◆ list_rules()

list[RuleInfo] oct.linter.rule_registry.list_rules ( )
Return all registered rules in registry order.

Definition at line 489 of file rule_registry.py.

Variable Documentation

◆ _VALID_SEVERITIES

oct.linter.rule_registry._VALID_SEVERITIES = frozenset({SEVERITY_BLOCKING, SEVERITY_ADVISORY, SEVERITY_INFO})
protected

Definition at line 53 of file rule_registry.py.

◆ SEVERITY_ADVISORY

str oct.linter.rule_registry.SEVERITY_ADVISORY = "advisory"

Definition at line 51 of file rule_registry.py.

◆ SEVERITY_BLOCKING

str oct.linter.rule_registry.SEVERITY_BLOCKING = "blocking"

Definition at line 50 of file rule_registry.py.

◆ SEVERITY_INFO

str oct.linter.rule_registry.SEVERITY_INFO = "info"

Definition at line 52 of file rule_registry.py.