From 1132e5386288ea2c0fa8ca3c47ffa8197c5109df Mon Sep 17 00:00:00 2001 From: Pawan Singh Kapkoti <42340841+Pawansingh3889@users.noreply.github.com> Date: Sat, 9 May 2026 18:50:26 +0100 Subject: [PATCH] chore: exclude test fixtures from the sql-sop dogfooding pre-commit hook The .pre-commit-config.yaml ran sql-sop with `--severity error` against every `*.sql` file in the repo. The only SQL files currently in the repo are the unit-test fixtures under tests/fixtures/ -- and those fixtures deliberately contain bad SQL (E001 DELETE without WHERE, E002 DROP without IF EXISTS, E003 GRANT/REVOKE, E004 string concatenation in WHERE, E005 INSERT without column list, E006 UPDATE without WHERE, plus warning- and structural-rule fixtures) so the rule unit tests can assert on those exact patterns. Result: pre-commit.ci has been reporting "Found 6 issues (6 errors) in 1 file" against tests/fixtures/errors.sql on every single PR for months. The pre-commit-ci status has been red the whole time but hidden behind the also-always-red validate check (just fixed by #50); on PRs that don't touch SQL fixtures, the dogfooding hook adds no diagnostic value because the failures are by design. Adding `exclude: ^tests/fixtures/` so the hook only runs against real SQL files outside the fixtures tree. No real .sql files exist in the repo today, so the hook is effectively dormant; the moment someone adds a migration script or an example query outside tests/fixtures/ it kicks in. Verified locally that the exclude pattern matches all four fixture files (clean.sql, contract_drift.sql, errors.sql, warnings.sql). --- .pre-commit-config.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d015867..c327702 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,11 +37,16 @@ repos: - id: ruff-format # ── sql-sop dogfooding itself ───────────────────────────────────── - # Runs sql-sop on the project's own fixtures + any staged .sql files - # so a regression in a rule is caught before it ships. + # Runs sql-sop on staged .sql files so a regression in a rule is + # caught before it ships. Test fixtures under ``tests/fixtures/`` are + # excluded because those files deliberately contain bad SQL + # (E001..E006, S001..S003, etc.) to drive the rule unit tests -- + # running the linter against them is guaranteed to fail and was + # turning pre-commit.ci red on every PR. - repo: https://github.com/Pawansingh3889/sql-guard rev: v0.7.0 hooks: - id: sql-sop args: [--severity, error] files: \.sql$ + exclude: ^tests/fixtures/