|
Option C Tools
|
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}) | |
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:
L3 — rule registry queries
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
------------
| RuleInfo | None oct.linter.rule_registry.get_rule_info | ( | str | name | ) |
Return the ``RuleInfo`` for *name*, or ``None`` if unknown.
Definition at line 340 of file rule_registry.py.
| 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 350 of file rule_registry.py.
| 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 367 of file rule_registry.py.
| list[RuleInfo] oct.linter.rule_registry.list_rules | ( | ) |
Return all registered rules in registry order.
Definition at line 345 of file rule_registry.py.
|
protected |
Definition at line 49 of file rule_registry.py.
| str oct.linter.rule_registry.SEVERITY_ADVISORY = "advisory" |
Definition at line 47 of file rule_registry.py.
| str oct.linter.rule_registry.SEVERITY_BLOCKING = "blocking" |
Definition at line 46 of file rule_registry.py.
| str oct.linter.rule_registry.SEVERITY_INFO = "info" |
Definition at line 48 of file rule_registry.py.