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

Layout/RescueEnsureAlignment not always correctly detecting alignment (again) #8717

Closed
Kjarrigan opened this issue Sep 15, 2020 · 1 comment
Labels

Comments

@Kjarrigan
Copy link

Expected behavior

Layout/BeginEndAlignment should correctly detect begin/rescue/end alignment.

Actual behavior

If begin/rescue/end is assigned to value then the alignment is being incorreclty detected:

Steps to reproduce the problem

Given this code:

results = begin
            client.search(q: query,
                          index: index,
                          from: cursor,
                          size: per_page,
                          sort: sort).dig('hits', 'hits').to_a
          rescue StandardError
            []
          end

elasticsearch.rb:224:21: C: Layout/RescueEnsureAlignment: rescue at 224, 20 is not aligned with results = begin at 218, 10.
                    rescue StandardError
                    ^^^^^^

Autocorrected to this:

results = begin
            client.search(q: query,
                          index: index,
                          from: cursor,
                          size: per_page,
                          sort: sort).dig('hits', 'hits').to_a
rescue StandardError
  []
          end

RuboCop version

$ [bundle exec] rubocop -V
0.91.0 (using Parser 2.7.1.4, rubocop-ast 0.4.0, running on ruby 2.7.1 x86_64-linux)

Related Issues

@koic koic added the bug label Sep 15, 2020
koic added a commit to koic/rubocop that referenced this issue Sep 15, 2020
…ment`

Fixes rubocop#8710 and rubocop#8717.

This PR fixes a false positive for `Layout/RescueEnsureAlignment`
when `Layout/BeginEndAlignment` cop is not enabled status (e.g. pending, disabled).

This patch includes workaround for pending status until RuboCop 1.0 is released.
@Kjarrigan
Copy link
Author

Can confirm fixed in master by #8719

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

No branches or pull requests

2 participants