Skip to content
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

Regression: Layout/RescueEnsureAlignment does not understand rescue inside of a block. #12404

Closed
shyouhei opened this issue Nov 22, 2023 · 0 comments · Fixed by #12405
Closed
Labels

Comments

@shyouhei
Copy link

It seems #5315 is happening again.

Expected behavior

No offenses for rescue inside a block inside a method.

Actual behavior

configuration from /dev/null
Default configuration from /usr/local/bundle/gems/rubocop-1.57.2/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning tmp.rb
Loading cache from /root/.cache/rubocop_cache/e740383ed1766bc3e7216af7a97ab0e0f1bcbe10/93ef223995b1081dff8ec247871eb71b25960a7c/b3b8a22f80e46edc790b147481c8332f57eeca49
C

Offenses:

tmp.rb:6:3: C: [Correctable] Layout/RescueEnsureAlignment: rescue at 6, 2 is not aligned with def foo at 3, 0.
  rescue StandardError
  ^^^^^^

1 file inspected, 1 offense detected, 1 offense autocorrectable
Finished in 0.1443319280006108 seconds

Steps to reproduce the problem

# frozen_string_literal: true

def foo
  [].each do
    bar _1
  rescue StandardError
    baz
  end
end

RuboCop version

1.57.2 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [x86_64-linux-musl]
  - rubocop-performance 1.19.1
  - rubocop-rails 2.22.2
  - rubocop-rspec 2.25.0
@koic koic added the bug label Nov 22, 2023
koic added a commit to koic/rubocop that referenced this issue Nov 22, 2023
…nment`

Fixes rubocop#12404.

This PR fixes a false positive for `Layout/RescueEnsureAlignment`
when aligned `rescue` in `do`-`end` numbered block in a method.
koic added a commit that referenced this issue Nov 23, 2023
…escue_ensure_alignment

[Fix #12404] Fix a false positive for `Layout/RescueEnsureAlignment`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants