Skip to content

feat(validators,git-diff): exclude glob + wrong-CWD guards (#335, #336)#337

Merged
fdaviddpt merged 1 commit into
masterfrom
feat/validator-exclude-and-cwd-guard
Jun 26, 2026
Merged

feat(validators,git-diff): exclude glob + wrong-CWD guards (#335, #336)#337
fdaviddpt merged 1 commit into
masterfrom
feat/validator-exclude-and-cwd-guard

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

What

Two dispatch/op ergonomics fixes, bundled (they overlap in supertool.py + CHANGELOG.md).

#335 — per-spec exclude glob (validators & formatters)

A validator/formatter spec may now set "exclude": "*tests/*" (string or list of globs, skip-if-any) to skip files even when match hits. Wired into _applicable_validators and _applicable_formatters via a shared _matches_any_glob helper.

Why: editing a PHPUnit test fired phpmd's TooManyPublicMethods — pure noise, since no real gate scans tests (CI mess-detection scans the source dir only; the pre-push git-hook skips /tests/). Per-spec on purpose: a blanket "skip tests" would break phpunit, which must run on tests.

#336 — wrong-CWD guards

git-diff:PATH previously reported a missing or untracked path as No changes. — a silent false-negative that masks a stale CWD. Path mode now checks git ls-files first:

  • missing → ⚠ not found under <cwd> — wrong CWD?, exit 1
  • untracked on-disk → ⚠ untracked (not in git)
  • tracked-clean → No changes. (correct)

Every mode also stamps a Repo: <toplevel> header so a wrong-repo invocation is visible at a glance. grep's path-not-found error now carries the CWD too.

Tests

12 new — exclude dispatch (×6), git-diff guard/header (×5, incl. tracked-modified-still-diffs regression), grep cwd (×1). 158 passed across the four affected suites.

Docs

docs/validators.md + validators/SCHEMA.md (exclude key), docs/presets/git.md (git-diff guard + Repo header), CHANGELOG.

Closes #335
Closes #336

Two dispatch/op ergonomics fixes:

#335 - per-spec `exclude` glob on validators & formatters. A spec may set
`"exclude": "*tests/*"` (string or list, skip-if-any) to skip files even when
`match` hits. Motivating case: editing a PHPUnit test fired phpmd's
TooManyPublicMethods - noise, since no real gate scans tests. Per-spec on
purpose: a blanket skip would break phpunit, which must run on tests.

#336 - git-diff:PATH no longer reports a missing/untracked path as "No changes."
(a silent false-negative that masks a wrong CWD). Path mode checks `git ls-files`
first: missing -> warn + exit 1, untracked -> warn, tracked-clean -> "No changes."
Every mode stamps a `Repo: <toplevel>` header so a wrong-repo invocation is
visible. grep's path-not-found error now carries the CWD too.

Tests: 12 new (exclude dispatch x6, git-diff guard/header x5, grep cwd x1).
Docs: validators.md + SCHEMA.md (exclude key), presets/git.md (guard + header).
Co-Authored-By: Max <noreply>
@fdaviddpt fdaviddpt merged commit b08d03f into master Jun 26, 2026
12 checks passed
@fdaviddpt fdaviddpt deleted the feat/validator-exclude-and-cwd-guard branch June 26, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant