KEMBAR78
[Fix #14413] Fix a false positive for `Layout/EmptyLinesAroundArguments` with multiline strings that contain only whitespace by Earlopain · Pull Request #14422 · rubocop/rubocop · GitHub
Skip to content

Conversation

@Earlopain
Copy link
Contributor

Fix #14413

The previous implementation was doing a bunch of work to decide if a line was supposed to be considered or not.
For example, Module.new with method definitions may contain newlines that should be ignored.

This new implementation only considers the ranges between arguments. The old implementation seemed to have issues with array-style method calls. To be honest, I did not try to understand the original implementation.

This implementation works by checking each argument (and also the closing bracket), looking to the left of it for whitespace and checking if that range goes over multiple lines.


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.

…Arguments` with multiline strings that contain only whitespace

The previous implementation was doing a bunch of work to decide if a line was
supposed to be considered or not.
For example, Module.new with method definitions may contain newlines that
should be ignored.

This new implementation only considers the ranges between arguments. The old implementationseemed
to have issues with array-style method calls. To be honest, I did not try to understand the original implementation.
@bbatsov bbatsov merged commit bf3806e into rubocop:master Aug 5, 2025
23 checks passed
@Earlopain Earlopain deleted the empty-lines-args-multiline-string branch September 3, 2025 12:10
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.

Unwarranted Layout/EmptyLinesAroundArguments

2 participants