-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[Fix #14443] Fix false positive in Layout/EmptyLinesAfterModuleInclusion
#14444
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 #14443] Fix false positive in Layout/EmptyLinesAfterModuleInclusion
#14444
Conversation
spec/rubocop/cop/layout/empty_lines_after_module_inclusion_spec.rb
Outdated
Show resolved
Hide resolved
…leInclusion` - Don't register an offense (and hence don't infinite loop when autocorrecting `Layout/EmptyLinesAfterModuleInclusion` and `Layout/EmptyLinesAroundBlockBody`) when the `include` send node is not followed by a constant argument. Example: ```ruby includes = [include, sdk_include].compact ``` vs. ```ruby include SdkIncludeModule ```
433a3c5 to
49c140b
Compare
|
Thanks @koic - I made those changes. |
|
|
||
| def on_send(node) | ||
| return if node.receiver | ||
| return if node.receiver || !node.arguments.one? |
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.
include and other module inclusion methods can take more than one argument, so this change introduces false negatives.
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.
Thanks! Hopefully #14455 is better?
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.
Looks good to me, thanks!
- The fix for `Layout/EmptyLinesAfterModuleInclusion` cop in 49c140b produced false negatives[1] when `include` and friends were, validly, called with multiple arguments. [1]: rubocop#14444 (comment)
- The fix for `Layout/EmptyLinesAfterModuleInclusion` cop in 49c140b produced false negatives[1] when `include` and friends were, validly, called with multiple arguments. [1]: rubocop#14444 (comment)
- The fix for `Layout/EmptyLinesAfterModuleInclusion` cop in 49c140b produced false negatives[1] when `include` and friends were, validly, called with multiple arguments. [1]: rubocop#14444 (comment)
Layout/EmptyLinesAfterModuleInclusionandLayout/EmptyLinesAroundBlockBody) when theinclude(or others affected by this cop) send node is/are not followed by a single argument (usually a constant).Example:
vs.
Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.