test(comments): no plan code lands in the code again
planCodes.contract.test.ts scans every tracked text file and every new one not yet added (comments, docstrings, test titles, lint messages alike) for an epic or roadmap code (`E28`, `E9.5`, `R14`) and for a sprint or review round cited on its own (`(S6)`, `S3e2`, `round 4`, `deep-review`). Not `E2E`, not a ruff rule family (`E4/E7/E9`), not a TV episode (`S2 · E5`, a test episode titled "E1"), not `S3h` (the media-card decision docs/DESIGN.md is headed by). Markdown and the Alembic migrations keep their history and are not scanned. One sweep test rather than an ESLint rule plus a ruff one: the codes sat in Python, TS, CSS, shell, TOML, YAML and lint messages, and no single linter reads all of them. Seen red on a planted backend/app file (all three plan-code lines named, its allowed line not). audit_metrics.py counts epic codes by the same definition (it used to miss `E9.5` and `R6`), and CLAUDE.md's "comment the why" rule names the test.
This commit is contained in:
@@ -25,9 +25,12 @@ BE_TESTS = ROOT / "backend" / "tests"
|
||||
FE_SRC = ROOT / "frontend" / "src"
|
||||
BIG_FILE = 800
|
||||
BE_COMPLEXITY = 10 # ruff's C901 default
|
||||
FE_COMPLEXITY = 20 # the frontend's line (E32)
|
||||
FE_COMPLEXITY = 20 # the frontend's line
|
||||
|
||||
EPIC_CODE = re.compile(r"\b(E\d{2}|R\d{1,2})(\s?S\d+)?\b")
|
||||
# what planCodes.contract.test.ts holds the code to: an epic (`E28`, `E9.5`) or a roadmap item (`R14`),
|
||||
# not `E2E`, not a ruff rule family (`E4/E7/E9`), not a TV episode (`S2 · E5`, an episode titled "E1")
|
||||
EPIC_CODE = re.compile(r'(?<![/"])\b(E\d{1,2}(\.\d+)?|R\d{1,2})\b(?![/"E])')
|
||||
EPISODE = re.compile(r"S\d{1,2}\s?·?\s?E\d+")
|
||||
NARRATION = re.compile(r"\b(used to|no longer)\b", re.IGNORECASE)
|
||||
|
||||
|
||||
@@ -111,7 +114,7 @@ def _complexity() -> dict[str, object]:
|
||||
|
||||
def _noise(be: list[tuple[Path, list[str]]], fe: list[tuple[Path, list[str]]]) -> dict[str, object]:
|
||||
every = be + fe
|
||||
epic = [(p, ln) for p, ls in every for ln in ls if EPIC_CODE.search(ln)]
|
||||
epic = [(p, ln) for p, ls in every for ln in ls if EPIC_CODE.search(EPISODE.sub("", ln))]
|
||||
be_c = sum(_comment_lines(ls, True) for _, ls in be)
|
||||
fe_c = sum(_comment_lines(ls, False) for _, ls in fe)
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user