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/RedundantException auto-correction does not keep parenthesization #5520

Closed
deivid-rodriguez opened this issue Jan 27, 2018 · 0 comments · Fixed by #5521
Closed

Style/RedundantException auto-correction does not keep parenthesization #5520

deivid-rodriguez opened this issue Jan 27, 2018 · 0 comments · Fixed by #5521

Comments

@deivid-rodriguez
Copy link
Contributor

Style/RedundantException auto-correction does not keep original parenthesization of the raise method call, and that can cause unparsable ruby.

Expected behavior

Rubocop keeps presence or absence of parentheses in the raise method call when auto-correcting.

Actual behavior

Rubocop removes parenthesis from the raise method call.

Steps to reproduce the problem

$ echo "system(*args) || raise(RuntimeError, 'hola')" | bundle exec rubocop --only Style/RedundantException --stdin file.rb --auto-correct
Inspecting 1 file
E

Offenses:

file.rb:1:18: C: [Corrected] Style/RedundantException: Redundant RuntimeError argument can be removed.
system(*args) || raise(RuntimeError, 'hola')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
file.rb:1:24: E: Lint/Syntax: unexpected token tSTRING
(Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
system(*args) || raise 'hola'
                       ^^^^^^

1 file inspected, 2 offenses detected, 1 offense corrected
====================
system(*args) || raise 'hola'

RuboCop version

$ rubocop -V
0.52.1 (using Parser 2.4.0.2, running on ruby 2.5.0 x86_64-linux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant