-
-
Notifications
You must be signed in to change notification settings - Fork 821
exclude_rules override in files are not used #5697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This may be more of a documentation issue. You can ignore rules at the file level, by doing this:
|
While the file-wide The issue here is that when it comes to lists (ignores, warnings, rules and exclude rules), the configuration object keeps the comma-separated string under the original key, e.g. This is only done during the configuration object initialization, typically after the content of the configuration file is parsed into a buffer and passed in. However, the inline configuration is read differently - the child configuration object is created and individual parameters are set on it as they are encountered in the SQL file they are declared. This means the list parsing into internal variables is done before the values are set. The code that assembles the applicable rule set to apply uses the internal variables |
Search before asking
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.
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:
We expect that running
sqlfluff lint --config config.toml query.sql
would result in no errors, as the file overrides:In actuality, linting fails, and only part of the overrides are honored:
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?
Code of Conduct
The text was updated successfully, but these errors were encountered: