standardrb / standard

Ruby's bikeshed-proof linter and formatter 🚲
Other
2.73k stars 214 forks source link

`--fix` mangles heredoc with postfix rescue clause #652

Closed bcdanieldickison closed 1 month ago

bcdanieldickison commented 1 month ago

example.rb:

foo(<<~EOF) rescue nil
  bar
EOF

standardrb --fix example.rb yields:

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

The correct fix would be something like:

begin
  foo(<<~EOF)
    bar
  EOF
rescue
  nil
end
searls commented 1 month ago

There is a high likelihood that this is a bug in whatever the associated Rubocop rule is. If you run without --fix you should be able to spot the name of the rule and file it there

bcdanieldickison commented 1 month ago

Filed the bug with Rubocop so will close this one. https://github.com/rubocop/rubocop/issues/13291