Description
Search before asking
- I searched the issues and found no similar issues.
What Happened
When setting sqlfluff:exclude_rules
in a file override, the override is not honored, for example, putting:
-- sqlfluff:exclude_rules:CP02
Expected Behaviour
The rule is excluded during the file. According to the docs, this is the preferred way to do file-specific overrides for rules.
When considering configuration inheritance, each of rules and exclude_rules will totally overwrite any values in parent config files if they are set in a child file. While the subtraction operation between both of them is calculated “per file”, there is no combination operation between two definitions of rules (just one overwrites the other).
The exclude_rules is overridden for that file.
Observed Behaviour
The rule is not excluded for the file. This is in contrast to other in-file overrides, which take effect for only the current file.
How to reproduce
Using the following example:
# config.toml
[sqlfluff]
dialect = ansi
[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower
-- query.sql
-- sqlfluff:exclude_rules:CP02
-- sqlfluff:rules:capitalisation.keywords:capitalisation_policy:upper
SELECT A FROM B.C;
We expect that running sqlfluff lint --config config.toml query.sql
would result in no errors, as the file overrides:
- CP02 (capitalisation.identifiers) is disabled (identifiers can be any case)
- keywords capitalization is set to upper
In actuality, linting fails, and only part of the overrides are honored:
== [query.sql] FAIL
L: 5 | P: 8 | CP02 | Unquoted identifiers must be lower case.
| [capitalisation.identifiers]
L: 5 | P: 15 | CP02 | Unquoted identifiers must be lower case.
| [capitalisation.identifiers]
L: 5 | P: 17 | CP02 | Unquoted identifiers must be lower case.
| [capitalisation.identifiers]
All Finished 📜 🎉!
This shows that just the rules exclusion was skipped.
Dialect
ansi
Version
sqlfluff, version 3.0.2
Python 3.8.10
Configuration
[sqlfluff]
dialect = ansi
[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower
Are you willing to work on and submit a PR to address the issue?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct