Style/ParenthesesAroundCondition
autocorrects code into invalid Ruby
#12529
Labels
Style/ParenthesesAroundCondition
autocorrects code into invalid Ruby
#12529
Style/ParenthesesAroundCondition
can sometimes autocorrect code into invalid Ruby.This seems to happen with multiline
while
statements.Expected behavior
RuboCop should not autocorrect in this case. Maybe it should also ignore this kind of scenario?
Actual behavior
It autocorrects this case, and thus produces 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
> rubocop -V 1.58.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin22]
The text was updated successfully, but these errors were encountered: