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

Questionable detection and autocorrect by Layout/RescueEnsureAlignment #9973

Closed
stoivo opened this issue Aug 2, 2021 · 0 comments · Fixed by #9974
Closed

Questionable detection and autocorrect by Layout/RescueEnsureAlignment #9973

stoivo opened this issue Aug 2, 2021 · 0 comments · Fixed by #9974
Labels

Comments

@stoivo
Copy link
Contributor

stoivo commented Aug 2, 2021

code:

['asdasdasda', 123, :simon, 13]
  .map do |part|
    part * 2
  rescue StandardError
    "can't be multiplied"
  end
  .tap { |res| puts res }

.rubocop

Style/FrozenStringLiteralComment:
  Enabled: false

Style/MultilineBlockChain:
  Enabled: false

Expected behavior

I expect rubocop to not to complain about my script.

Actual behavior

rubocop's output

Offenses:

scripts/console.rb:4:3: C: [Correctable] Layout/RescueEnsureAlignment: rescue at 4, 2 is not aligned with ['asdasdasda', 123, :simon, 13]
  .map do at 1, 0.
  rescue StandardError
  ^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable

and the proposes autofix

['asdasdasda', 123, :simon, 13]
  .map do |part|
    part * 2
rescue StandardError
  "can't be multiplied"
  end
  .tap { |res| puts res }
$ bundle exec rubocop -V 
1.18.4 (using Parser 3.0.2.0, rubocop-ast 1.8.0, running on ruby 3.0.2 x86_64-darwin20)
$ gem list "rubocop-*"
*** LOCAL GEMS ***
rubocop (1.18.4)
rubocop-ast (1.8.0)

Anyway, thanks for a very handy tool.

@koic koic added the bug label Aug 2, 2021
koic added a commit to koic/rubocop that referenced this issue Aug 4, 2021
…ment`

Fixes rubocop#9973.

This PR fixes a false positive for `Layout/RescueEnsureAlignment`
when aligned `rescue` keyword and leading dot.
bbatsov pushed a commit that referenced this issue Aug 12, 2021
Fixes #9973.

This PR fixes a false positive for `Layout/RescueEnsureAlignment`
when aligned `rescue` keyword and leading dot.
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