-
Notifications
You must be signed in to change notification settings - Fork 208
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
Standard "corrects"return *array
to something unparseable
#277
Labels
rubocop bug 🚨
An apparent bug in RuboCop
Comments
8 tasks
Thank you for opening the issue. This is a RuboCop's bug and I opened rubocop/rubocop#9631 to RuboCop core. |
koic
added a commit
to koic/rubocop
that referenced
this issue
Mar 22, 2021
Fixes standardrb/standard#277. This PR fixes the following false positive for `Style/RedundantReturn` when using `return` with splat argument. ```console % cat example.rb class MyClass def something data = [1, 2, 3] return *data end end ``` ## Before Auto-corrected to invalid code. ```console % rubocop --only Style/RedundantReturn -a (snip) % cat example.rb class MyClass def something data = [1, 2, 3] *data end end % ruby -c example.rb example.rb:4: syntax error, unexpected '\n', expecting '=' ``` ## After Auto-corrected to valid code. ```console % rubocop --only Style/RedundantReturn -a (snip) % cat example.rb class MyClass def something data = [1, 2, 3] data end end % ruby -c example.rb Syntax OK ```
Thanks for the quick fix @koic! |
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this issue
Mar 22, 2021
Fixes standardrb/standard#277. This PR fixes the following false positive for `Style/RedundantReturn` when using `return` with splat argument. ```console % cat example.rb class MyClass def something data = [1, 2, 3] return *data end end ``` ## Before Auto-corrected to invalid code. ```console % rubocop --only Style/RedundantReturn -a (snip) % cat example.rb class MyClass def something data = [1, 2, 3] *data end end % ruby -c example.rb example.rb:4: syntax error, unexpected '\n', expecting '=' ``` ## After Auto-corrected to valid code. ```console % rubocop --only Style/RedundantReturn -a (snip) % cat example.rb class MyClass def something data = [1, 2, 3] data end end % ruby -c example.rb Syntax OK ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given this
issue.rb
source file:...
standardrb
reports an issue:When running it with
--fix
, it "corrects" it by removing thereturn
but leaving the*
, rendering it unparseable:Here's the final version of
issue.rb
after the "fix" was applied:When
return *array
is used I thinkstandardb --fix
should strip both thereturn
and the*
.The text was updated successfully, but these errors were encountered: