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
New Rule L052: Semi colon alignment #1902
Conversation
@barrywhart took a couple attempts to track down all the places this impacted in the dbt tests, but this should be good for review now 😄 |
Codecov Report
@@ Coverage Diff @@
## main #1902 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 142 143 +1
Lines 10090 10152 +62
=========================================
+ Hits 10090 10152 +62
Continue to review full report at Codecov.
|
I don't think this is an anti-pattern. It's fairly standard in large queries
|
Personally I like this rule! What about an optional config to also allow them to be on a newline (with no extra newlines in between) to keep the @WittierDinosaur 's of the world happy too? In which case should this be enforced or only allowed? Which should |
@WittierDinosaur @tunetheweb sure thing! I don't think it should be too hard to add that option. The way it will work is user has an option of either semi-colon on same line OR new line, but not both. Consistency should be encouraged. The default will be to use same line. |
@alanmcruickshank ah was not aware of that, agree that your approach to disable the trailing semi-colon by default is pragmatic though, will tweak the default config 👍 |
If we're taking that option - would you mind removing the semi-colons from the tests in the dbt tests. I'm happy for them to stay on the core tests - but I think that sets the right expectation for performance with dbt. Bonus points if you make a note in the default config to that effect. |
Will do! 😄 |
* Implement generic placeholder templating * Add %s placeholder too * Add tests and check for the config state * Remove typo and improve wording of the documentation for placeholder Co-authored-by: Barry Hart <barrywhart@yahoo.com> Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Add tox commands to streamline release workflow * typo in tox env name Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
…fluff into semi_colon_alignment
Addressed the "allow_final_semi_colon" being set to true by default point. Will move on to looking at the option for semi-colons on a new line now |
@WittierDinosaur @tunetheweb @alanmcruickshank I've added the options to configure the behaviour of rule L052 as we described above. I've also added extra unit tests for the config options. Should be good to go if you're happy with it 😄 |
…fluff into semi_colon_alignment
@barrywhart Ready for review 😄 |
Tagging other commenters for review. I'll take a look as well. |
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
@tunetheweb @barrywhart think we can merge this, L053, and L054 down once the final CI checks are done, I've addressed all the suggestions and test cases look good |
Brief summary of the change made
This PR introduces a new rule L052. It serves two purposes, one to snap semi-colons to the end of the preceding statement, and the other to add the final trailing semi-colon if it is missing:
I have added a configuration option called
allow_final_semi_colon
(which defaults to False) so users can allow missing final semi-colons if they desire (I'm happy to change the default to True on this if you would prefer, but my preference is to add the final semi-colons by default).This change impacts quite a few unit tests, solely because we weren't previously including final semi-colon, so I have gone through and added the semi-colon/excluded the rule where I think appropriate.
Fixes #1748
Are there any other side effects of this change that we should be aware of?
No
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 withpython test/generate_parse_fixture_yml.py
or by runningtox
locally).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.