Skip to content

feat: Add --severity filter and fix --exclude/--fail-fast#17

Merged
danthompson merged 2 commits into
mainfrom
feat/filter-consolidation-and-severity
May 11, 2026
Merged

feat: Add --severity filter and fix --exclude/--fail-fast#17
danthompson merged 2 commits into
mainfrom
feat/filter-consolidation-and-severity

Conversation

@danthompson
Copy link
Copy Markdown
Member

  • Add --severity warn|error to check. Filters reported violations by threshold (warn-and-above, or errors-only). Orthogonal to --fail-on: --severity gates what is reported; --fail-on gates the exit code.
  • Fix --exclude X --fail-fast (and --select Y --fail-fast) producing empty results when other rules would have fired. Rule-ID filtering now runs before evaluation rather than after, so --fail-fast stops at the first violation among the remaining rules instead of one that gets stripped post-hoc.
  • Extract a filters.py module hosting the resource-exclusion, rule-ID, and severity filters. Engine and _lint.run() import from it. No user-facing behavior change beyond the bug fix.

Move rule-ID, resource-eligibility, and violation-exclusion filters into
a new dbt_lint.filters module. Apply rule-ID filtering before evaluation
so --fail-fast no longer masks violations when --select/--exclude is set.

Previously, run() filtered violations by rule ID after the engine had
already short-circuited on --fail-fast. Excluding the rule that fires
first stripped its violation post-hoc and returned an empty result,
even though other rules would have fired. filter_rules_by_id now
narrows the rule list before dispatch, so the excluded rule never
consumes the fail-fast slot.

Filter behavior is unit-tested in test_filters.py; engine and run()
tests no longer duplicate those assertions. A shared make_rule fixture
consolidates three near-identical local factories.
Filter reported violations by minimum severity. `--severity warn` shows
warn and error violations; `--severity error` shows only error
violations. Default (unset) preserves prior behavior of reporting all
severities.

`--severity` and `--fail-on` are orthogonal: --severity controls what
is reported, --fail-on controls the exit code.
@danthompson danthompson marked this pull request as ready for review May 11, 2026 21:01
@danthompson danthompson merged commit c536c40 into main May 11, 2026
5 checks passed
@danthompson danthompson deleted the feat/filter-consolidation-and-severity branch May 11, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant