File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6868 run : |
6969 python - <<'PY'
7070 import json
71+ import re
7172 import sys
7273
7374 with open("harper-report.json", encoding="utf-8") as f:
8182 ("Spelling", "DisjointPrefixes"),
8283 }
8384
85+ def should_ignore_spelling_text(text):
86+ if not text:
87+ return False
88+
89+ stripped = text.strip()
90+
91+ # URLs and URL fragments
92+ if stripped.startswith(("http://", "https://", "www.")):
93+ return True
94+
95+ # File paths / command paths
96+ if "/" in stripped:
97+ return True
98+
99+ # Long hashes, IDs, tokens
100+ if len(stripped) >= 16 and any(c.isdigit() for c in stripped):
101+ return True
102+
103+ # Hex-like strings, e.g. d5442a5dc4baadd48b32
104+ if len(stripped) >= 8 and re.fullmatch(r"[a-fA-F0-9]+", stripped):
105+ return True
106+
107+ # Mostly random-looking alphanumeric tokens
108+ if len(stripped) >= 12 and re.fullmatch(r"[A-Za-z0-9_-]+", stripped):
109+ return True
110+
111+ return False
112+
84113 for report in reports:
85114 file = report.get("file")
86115
96125 if (kind, rule) in IGNORED_RULES:
97126 continue
98127
128+ if kind == "Spelling" and should_ignore_spelling_text(text):
129+ continue
130+
99131 if kind in {"Spelling", "Grammar", "Repetition"}:
100132 selected.append(
101133 f"{file}:{line_no}: [{kind}::{rule}] {text!r} - {message}"
You can’t perform that action at this time.
0 commit comments