Skip to content
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

Fix extra underscores in case rules (L010 and L014) #1396

Merged

Conversation

tunetheweb
Copy link
Member

@tunetheweb tunetheweb commented Sep 13, 2021

Brief summary of the change made

Fixes #1394

Are there any other side effects of this change that we should be aware of?

Currently the rules were setting Pascal capitalisation policy to be an alternative to underscores, and so adding and removing underscores when fixing case issues.

ThisIsAnExample (pascal case) -> this_is_an_example (lowercase)
this_is_an_example (lowercase) -> ThisIsAnExample (pascal case)

This is not my understanding of Pascal Case should be converted, and is more like Snake Case.

With this PR, we now leave underscores alone.

The rules were also lowercasing Capital letters in the middle or words which is, again, not my understanding of PascalCase (as it's name suggests!)

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 in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/parser (note YML files can be auto generated with python test/generate_parse_fixture_yml.py or by running tox locally).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@tunetheweb
Copy link
Member Author

See also this comment where some of these rules were decided: #820 (comment)

@tunetheweb
Copy link
Member Author

FYI: @panasenco

@WittierDinosaur
Copy link
Contributor

I agree with most of your comments, barring one. #820 (comment)

@tunetheweb
Copy link
Member Author

I agree with most of your comments, barring one. #820 (comment)

We've discussed on that thread and explained my reasoning, and think we've agreed now on what's been implemented here. So all good to review.

But thanks for looking and challenging! Always good to hear opinions and thrash things out to make sure what's being proposed is correct.

Copy link
Member

@barrywhart barrywhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, but I'm not the most qualified person for the casing stuff. Think we should tag the original author of this work? IIRC, it was contributed about 4 months ago, so they may still be available.

@tunetheweb
Copy link
Member Author

Looks reasonable to me, but I'm not the most qualified person for the casing stuff. Think we should tag the original author of this work? IIRC, it was contributed about 4 months ago, so they may still be available.

See the comment two above this 😁

There was a robust conversation with @WittierDinosaur on this in that other thread and I eventually managed to persuade him round to what we have here. Will give it a day or two to see if any more comments and, if not, merge.

@barrywhart
Copy link
Member

@tunetheweb: Ah yes, I see some of the earlier discussion now. I'm 👍 for not adding/removing underscores due to the danger of breaking previously working code. I'll throw out there, one option that I don't think y'all considered would be to warn about non-complying code but not provide automatic fixes if it would involve adding/removing underscores or something dangerous like that. No strong feelings about whether to do this. Possibly a future option depending on other reviewers' thoughts and/or the eventual user feedback.

@codecov
Copy link

codecov bot commented Sep 14, 2021

Codecov Report

Merging #1396 (b1422f1) into main (178e2a1) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1396   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          127       127           
  Lines         8553      8550    -3     
=========================================
- Hits          8553      8550    -3     
Impacted Files Coverage Δ
src/sqlfluff/rules/L010.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6eaf5c...b1422f1. Read the comment docs.

@tunetheweb tunetheweb merged commit 398ed74 into sqlfluff:main Sep 15, 2021
@tunetheweb tunetheweb deleted the fix-extra-underscores-in-case-rules branch September 15, 2021 06:36
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.

L014 Inserting underscores after numbers in unquoted identifiers
3 participants