Option C Tools
Loading...
Searching...
No Matches
waivers Namespace Reference

Functions

dict[int, dict] parse_inline_waivers (str text)

Variables

 _WAIVER_RE

Detailed Description

Purpose
-------
OI-540 — shared inline-waiver parsing for OCT-LINT comments.

Extracted from :mod:`oct.linter.oct_lint` so that both the linter and
the quality gate (:mod:`oct.git.quality_gate`) can import the same
parser without the quality gate depending on the linter.

Responsibilities
----------------
- Host :data:`_WAIVER_RE` — the canonical regex for
  ``# OCT-LINT: disable=<rule> [reason="..."]`` comments.
- Provide :func:`parse_inline_waivers` — returns a mapping of
  line numbers to ``{"rule": str, "reason": str|None}`` dicts.

Diagnostics
-----------
Domain: OCT-CORE
Levels:
    (No diagnostics emitted — pure parsing helper.)

Contracts
---------
- Must not import :mod:`oct.linter.oct_lint` (no circular dependency).
- Return shape is stable — both linter and quality gate depend on it.

Dependencies
------------

Function Documentation

◆ parse_inline_waivers()

dict[int, dict] waivers.parse_inline_waivers ( str text)
Parse ``# OCT-LINT: disable=<rule> [reason]`` comments from source.

Returns a dict mapping line numbers (1-based) to
``{"rule": str, "reason": str|None}``.

Definition at line 47 of file waivers.py.

Variable Documentation

◆ _WAIVER_RE

waivers._WAIVER_RE
protected
Initial value:
1= re.compile( # OCT-LINT: disable=no_hardcoded_secrets reason="Waiver regex pattern, not a secret"
2 r'#\s*OCT-LINT:\s*disable\s*=\s*(?P<rule>[a-z_]+)(?:\s+(?P<reason>.*))?',
3 re.IGNORECASE,
4)

Definition at line 41 of file waivers.py.