-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Style/AccessorGrouping autocorrect leaves behind empty lines #8406
Comments
This is intended behavior to avoid complicating the cop. Those empty lines will be further corrected by class Chef
class HTTP
attr_reader :url
attr_reader :sign_on_redirect
attr_reader :redirect_limit
attr_reader :options
attr_reader :middlewares
end
end
class Chef
class HTTP
attr_reader :url, :sign_on_redirect, :redirect_limit, :options, :middlewares
end
end |
I wouldn't assume that all users have every cop enabled and aren't just autocorrecting their codebases one rule at a time. When using a corrector.remove you should really make sure that you remove everything and not just the trailing text on the line. It's not a significant amount of complexity to add that. Here's an example where we're making sure we cleanup our whitespace in Cookstyle: |
## Summary Fixes rubocop#8406. This PR improves `Style/AccessorGrouping`'s auto-correction to remove redundant blank lines. ## Other Information This PR doesn't update to `Cop::Base` to make it clear the difference between the changes. Will be updated with other `Style` cops in different PR.
If it introduces implementation complexity that is not essential for cop purposes, it may be possible to delegate partial auto-corrections to other cop. I opened the PR #8410 due to the implementation added is simple at this time. Thank you. |
…ssor_grouping [Fix #8406] Improve `Style/AccessorGrouping`'s auto-correction
Expected behavior
Left whitespace would be included in the node being removed
Actual behavior
Empty lines are left because the
attr_reader
entries are indentedSteps to reproduce the problem
Autocorrect this:
Results in:
RuboCop version
The text was updated successfully, but these errors were encountered: