KEMBAR78
[Fix #14443] Fix false positive in `Layout/EmptyLinesAfterModuleInclusion` by issyl0 · Pull Request #14444 · rubocop/rubocop · GitHub
Skip to content

Conversation

@issyl0
Copy link
Contributor

@issyl0 issyl0 commented Aug 13, 2025

Example:

includes = [include, sdk_include].compact

vs.

include SdkIncludeModule

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…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
```
@issyl0 issyl0 force-pushed the fix-false-positive-module-inclusion-cop branch from 433a3c5 to 49c140b Compare August 14, 2025 23:35
@issyl0
Copy link
Contributor Author

issyl0 commented Aug 14, 2025

Thanks @koic - I made those changes.

@koic koic merged commit f6ead10 into rubocop:master Aug 15, 2025
23 checks passed
@issyl0 issyl0 deleted the fix-false-positive-module-inclusion-cop branch August 15, 2025 16:45

def on_send(node)
return if node.receiver
return if node.receiver || !node.arguments.one?
Copy link
Contributor

@lovro-bikic lovro-bikic Aug 15, 2025

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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!

issyl0 added a commit to issyl0/rubocop that referenced this pull request Aug 17, 2025
- 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)
issyl0 added a commit to issyl0/rubocop that referenced this pull request Aug 17, 2025
- 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)
issyl0 added a commit to issyl0/rubocop that referenced this pull request Aug 18, 2025
- 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)
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.

Infinite loop caused by Layout/EmptyLinesAfterModuleInclusion -> Layout/EmptyLinesAroundBlockBody

3 participants