KEMBAR78
Fix false negative for `Layout/EndAlignment` when `end` is not on a separate line by lovro-bikic · Pull Request #14474 · rubocop/rubocop · GitHub
Skip to content

Conversation

lovro-bikic
Copy link
Contributor

@lovro-bikic lovro-bikic commented Aug 25, 2025

Registers offenses for code such as:

module Foo
  bar end

if test
  foo
else
  bar end

and autocorrects it to:

module Foo
  bar
end

if test
  foo
else
  bar
end

Note that such offenses have been previously ignored as false positives in 4bfe82e, which resolved #7778. It mentions introduction of Layout/BlockEndNewline, but that cop doesn't handle these kind of offenses, and doesn't seem like the right place for them.


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.


expect_correction(<<~RUBY)
module A
puts a#{trailing_whitespace}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trailing whitespace is further handled by Layout/TrailingWhitespace.

@koic koic merged commit 6e5c599 into rubocop:master Aug 26, 2025
22 checks passed
@lovro-bikic lovro-bikic deleted the false-negative-end-alignment branch August 26, 2025 06:19
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.

Layout/EndAlignment can't autocorrect condensed case statements

2 participants