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

Proposed graceful handling of noqa by L016 (#4248) #4424

Merged
merged 9 commits into from Feb 26, 2023

Conversation

alanmcruickshank
Copy link
Member

@alanmcruickshank alanmcruickshank commented Feb 23, 2023

This is a fairly blunt (but IMHO, safe) treatment of -- noqa comments by L016. This resolves #4248.

We already detect trailing inline comments in L016 so that we can handle them differently. This explicitly handles two cases as unfixable:

  1. Any comments which are, just by their own length, going to just cause another error if we move them.
  2. Any noqa comments.

Effectively - if a line is too long with a noqa, then we won't touch it - we will still report the error. The code diff looks worse than it is, just because I've added some if statements and indented pre-existing code by another step.

@coveralls
Copy link

coveralls commented Feb 23, 2023

Pull Request Test Coverage Report for Build 4276411030

  • 14 of 14 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 4275474886: 0.0%
Covered Lines: 17229
Relevant Lines: 17229

💛 - Coveralls

@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (6dc2ed9) compared to base (0a6b1d3).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4424   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          206       206           
  Lines        15391     15397    +6     
=========================================
+ Hits         15391     15397    +6     
Impacted Files Coverage Δ
src/sqlfluff/utils/reflow/reindent.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@WittierDinosaur WittierDinosaur left a comment

Choose a reason for hiding this comment

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

LGTM

)

# Sense check a few edge cases:
if "noqa" in line_buffer[-1].segments[-1].raw:
Copy link
Contributor

Choose a reason for hiding this comment

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

Approved, but is this an ideal way to check noqa? Wouldn't this also fail on SELECT * FROM myschema.mynoqatable? Would we not want to verify type as a Comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah - good thought - but we've just confirmed that it's a comment on line 1659, so I think this is safe here.

@alanmcruickshank alanmcruickshank enabled auto-merge (squash) February 26, 2023 18:42
@alanmcruickshank alanmcruickshank merged commit 668bcde into main Feb 26, 2023
@alanmcruickshank alanmcruickshank deleted the ac/noqa_comments branch February 26, 2023 18:59
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.

noqa comments on long lines incorrectly moved to its own line
3 participants