Style/RedundantParentheses
autocorrects code into invalid Ruby
#12298
Labels
Style/RedundantParentheses
autocorrects code into invalid Ruby
#12298
Style/RedundantParentheses
can sometimes autocorrect code into invalid Ruby.This can happen when passing in an argument to a function that consists of calling a method on a hash.
Expected behavior
RuboCop should not autocorrect in this case. I also think the
Style/RedundantParentheses
should probably ignore this scenario as well.Actual behavior
It autocorrects this case, and thus produced invalid Ruby (which RuboCop cannot parse).
When running
rubocop -A --debug test.rb
(see the below example from the "Steps to reproduce the problem" section), I see:Steps to reproduce the problem
Create a file
test.rb
You can run this file
ruby test.rb
and nothing breaks.If you run
rubocop -A test.rb
, it autocorrects the file to:This file cannot be parsed - if you try to run it by doing
ruby test.rb
or if you try to run rubocop on it (rubocop test.rb
) it will fail.RuboCop version
The text was updated successfully, but these errors were encountered: