-
-
Notifications
You must be signed in to change notification settings - Fork 873
Fix spacing rules for functions #5809
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
Conversation
…res-bare-function-spacing
Coverage Results ✅
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall things look good, some very nice clean up. There are a few parse_mode
lines left in commented out that could be removed. The Sequence(Bracketed(...))
pattern feels redundant, but that's more of a preference thing.
optional=True, | ||
), | ||
), | ||
# parse_mode=ParseMode.GREEDY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented line can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed on these, will sort tomorrow
|
||
type = "function_contents" | ||
|
||
match_grammar = Sequence( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Sequence is not required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting quirk that we should probably fix. You cannot start a match grammar with Bracketed(). The sequence wrapping allows it to work, OneOf, AnyOf, etc would also work. It you remove the Sequence here, it breaks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that is interesting.
# The brackets might be empty for some functions... | ||
optional=True, | ||
), | ||
# parse_mode=ParseMode.GREEDY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented line.
"FunctionContentsGrammar", | ||
), | ||
), | ||
# parse_mode=ParseMode.GREEDY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented line.
Co-authored-by: Cameron <105471409+keraion@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the change this LGTM!
Brief summary of the change made
Function names shouldn't have touch after, function parameters should have touch before - as functions can be bare.
Fixes #5808
Fixes #5869
Fixes #5978
Are there any other side effects of this change that we should be aware of?
Hopefully no knock on effects. I reckon now that we have the function_contents segment, a few rules can be rewritten in a more elegant way - but this PR is already crowded enough. It may be worth a minor release due to the sheer size of the code change.
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.