A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/14309 below:

`Style/SoleNestedConditional` incorrectly autofixes condition with assignment · Issue #14309 · rubocop/rubocop · GitHub

Autofix for Style/SoleNestedConditional breaks my code, despite being flagged as safe

export RUBOCOP_TARGET_RUBY_VERSION=3.3
echo "
if 'truthy' && assigned = '1'
  if '2'
    puts assigned
  end
end
" | rubocop --stdin user.rb --only 'Style/SoleNestedConditional' -a
Expected behavior

Correction shouldn't change original code's behaviour (prints 1), ie:

if 'truthy' && (assigned = '1') && '2'
  puts assigned
end
Actual behavior

Correction changes original code's behaviour (prints 2):

if 'truthy' && assigned = '1' && '2'
  puts assigned
end
Steps to reproduce the problem

As above

RuboCop version

1.76.2 (using Parser 3.3.8.0, Prism 1.4.0, default, rubocop-ast 1.45.1, analyzing as Ruby 3.3, running on ruby 3.3.6) [x86_64-linux]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4