Return a per-line bitmap; True means the line sits inside a `// code-format off` / `// code-format on` fence and must be skipped by every rule. The fence lines themselves are masked too so they don't get flagged as multi-line comment runs.
(lines: list[str])
| 880 | |
| 881 | |
| 882 | def _compute_fence_mask(lines: list[str]) -> list[bool]: |
| 883 | """Return a per-line bitmap; True means the line sits inside a |
| 884 | `// code-format off` / `// code-format on` fence and must be skipped by |
| 885 | every rule. The fence lines themselves are masked too so they don't get |
| 886 | flagged as multi-line comment runs.""" |
| 887 | mask = [False] * len(lines) |
| 888 | fenced = False |
| 889 | for i, line in enumerate(lines): |
| 890 | if _FENCE_OFF_RE.match(line): |
| 891 | fenced = True |
| 892 | mask[i] = True |
| 893 | continue |
| 894 | if _FENCE_ON_RE.match(line): |
| 895 | fenced = False |
| 896 | mask[i] = True |
| 897 | continue |
| 898 | mask[i] = fenced |
| 899 | return mask |
| 900 | |
| 901 | |
| 902 | def _is_line_comment(line: str) -> bool: |