diff --git a/scripts/repo-scan.py b/scripts/repo-scan.py index 6bea156..6146041 100644 --- a/scripts/repo-scan.py +++ b/scripts/repo-scan.py @@ -24,9 +24,11 @@ PRUNE = {".git", ".venv", ".collections", ".ansible", ".worktrees", SKIP_PREFIX = os.path.join("docs", "reviews") # don't scan our own reports SOURCE_EXTS = {".yml", ".yaml", ".j2", ".py", ".sh", ".md", ".tf", ".cfg", ".ini"} -# Marker words, but NOT when part of a regex alternation `(TODO|...)` or a filename -# like `TODO.md` / `docs/TODO.md`. -MARKER_RE = re.compile(r"(?*${}") @@ -198,6 +200,15 @@ def scan(): ref = pm.group(0).rstrip(".,);:`'\"") if any(c in ref for c in PLACEHOLDER): continue + # Skip template / generated-report paths — not real broken refs: + # - a placeholder (, ${x}) immediately follows the matched path + # (the regex stops at the placeholder, so it isn't caught above) + # - a date-template token (YYYY-MM-DD) appears in the path + # - the path is under a generated-report `reviews/` directory + if (cand[pm.end():pm.end() + 1] in PLACEHOLDER + or re.search(r"YYYY|MM-DD", ref) + or re.search(r"(?:^|/)reviews/", ref)): + continue if not os.path.exists(os.path.join(ROOT, ref)): findings.append({"check": "broken-path-ref", "severity": "medium", "path": rpath, "line": i, "detail": f"references '{ref}' which does not exist"})