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

Style/RescueModifier --fix mangles heredoc #13291

Closed
bcdanieldickison opened this issue Oct 3, 2024 · 0 comments · Fixed by #13292
Closed

Style/RescueModifier --fix mangles heredoc #13291

bcdanieldickison opened this issue Oct 3, 2024 · 0 comments · Fixed by #13292
Labels

Comments

@bcdanieldickison
Copy link

Originally reported in standardrb/standard#652

Given example.rb:

foo(<<~EOF) rescue nil
  bar
EOF

standardrb --fix example.rb creates syntactically invalid output from the Style/RescueModifier rule.

Expected behavior

begin
  foo(<<~EOF)
    bar
  EOF
rescue
  nil
end

Actual behavior

begin
  foo(<<~EOF)
rescue
  nil
end
  bar
EOF

Steps to reproduce the problem

  1. Create example.rb as above
  2. Run standardrb --fix example.rb

RuboCop version

standardrb -V
Standard version: 1.40.0
RuboCop version:  1.65.1 (using Parser 3.3.4.2, rubocop-ast 1.32.1, running on ruby 3.3.5) [arm64-darwin24]
@koic koic added the bug label Oct 3, 2024
koic added a commit to koic/rubocop that referenced this issue Oct 3, 2024
…ifier`

Fixes rubocop#13291.

This PR fixes an incorrect autocorrect for `Style/RescueModifier`
when using modifier rescue for method call with heredoc argument.
koic added a commit to koic/rubocop that referenced this issue Oct 3, 2024
…ifier`

Fixes rubocop#13291.

This PR fixes an incorrect autocorrect for `Style/RescueModifier`
when using modifier rescue for method call with heredoc argument.

The autocorrection of heredoc indentation after autocorrect will be left to other cops,
such as `Layout/ClosingHeredocIndentation` and `Layout/HeredocIndentation`.
koic added a commit that referenced this issue Oct 4, 2024
…style_rescue_modifier

[Fix #13291] Fix an incorrect autocorrect for `Style/RescueModifier`
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