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 in 0.91.0 in Layout/RescueEnsureAlignment #8760

Closed
jcoyne opened this issue Sep 21, 2020 · 7 comments
Closed

Regression in 0.91.0 in Layout/RescueEnsureAlignment #8760

jcoyne opened this issue Sep 21, 2020 · 7 comments
Assignees

Comments

@jcoyne
Copy link

jcoyne commented Sep 21, 2020

Previously this was valid:

    request_model = begin
                      'something'
                    rescue StandardError => e
                      return 'other stuff'
                    end

But now after upgrading to 0.91.0 this trips: Layout/RescueEnsureAlignment

Possibly due to changes https://github.com/rubocop-hq/rubocop/pull/8628/files#diff-e066e4a443e8fb75fe62f10fef9c6866R24

@koic
Copy link
Member

koic commented Sep 21, 2020

This issue is a dup with #8710 and resolved by #8719. Please wait a moment for the next release. Thank you for the feedback.

@koic koic closed this as completed Sep 21, 2020
@mvz
Copy link
Contributor

mvz commented Sep 24, 2020

I'm still seeing this with RuboCop 0.91.1.

@koic
Copy link
Member

koic commented Sep 24, 2020

@mvz I cannot reproduce this issue with RuboCop 0.91.1. Can you provide the issue code?

@mvz
Copy link
Contributor

mvz commented Sep 25, 2020

@koic here's a simple reproduction:

foo.rb:

# frozen_string_literal: true

foo = begin
        bar
      rescue StandardError
        baz
      end

qux foo

.rubocop.yml:

AllCops:
  NewCops: enable

Output:

$ rubocop foo.rb
Inspecting 1 file
W

Offenses:

foo.rb:5:7: C: Layout/RescueEnsureAlignment: rescue at 5, 6 is not aligned with foo = begin at 3, 0.
      rescue StandardError
      ^^^^^^
foo.rb:7:7: W: Layout/BeginEndAlignment: end at 7, 6 is not aligned with foo = begin at 3, 0.
      end
      ^^^

1 file inspected, 2 offenses detected, 2 offenses auto-correctable

RuboCop version info:

0.91.1 (using Parser 2.7.1.5, rubocop-ast 0.5.0, running on ruby 2.7.1 x86_64-linux)

@mvz
Copy link
Contributor

mvz commented Sep 25, 2020

I get the same result with the following .rubocop.yml:

Layout/BeginEndAlignment:
  Enabled: true

@koic
Copy link
Member

koic commented Sep 25, 2020

@mvz I get it. The default configuration for Layout/BeginEndAlignment is EnforcedStyleAlignWith: start_of_line. You can get the expected behavior by setting alternative EnforcedStyleAlignWith: begin to your .rubocop.yml.

Layout/BeginEndAlignment:
  Enabled: true
  EnforcedStyleAlignWith: begin

https://docs.rubocop.org/rubocop/0.92/cops_layout.html#layoutbeginendalignment

@mvz
Copy link
Contributor

mvz commented Sep 26, 2020

@koic Thanks for looking into this. Changing the EnforcedStyleAlignWith to begin works for me!

I'm a little confused by the difference in default settings between Layout/BeginEndAlignment and Layout/EndAlignment, but that's another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants