A RetroSearch Logo

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

Search Query:

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

v1.79.0 introduced unsafe auto correct to Lint/UselessAssignment · Issue #14394 · rubocop/rubocop · GitHub

def testing
  attempts ||= 1

  do_something
rescue Exception1 => e
  raise e if attempts > 2

  # does something

  attempts += 1
  retry
rescue Exception2 => e
  raise e if attempts > 2

  # does something

  attempts += 1
  retry
end
Expected behavior

Should not change this block of code at all

Actual behavior

The cop makes the first instance of attempts += 1 into attempts + 1, which then splits into attempts\n1, which then gets removed entirely by Lint/Void.

Steps to reproduce the problem

Use above code sample in file.rb, and run rubocop -A file.rb

RuboCop version
› bundle exec rubocop -V
1.79.0 (using Parser 3.3.9.0, Prism 1.4.0, parser_prism, rubocop-ast 1.46.0, analyzing as Ruby 3.4, running on ruby 3.4.4) [arm64-darwin24]
  - rubocop-rails 2.32.0
  - rubocop-performance 1.25.0
  - rubocop-rspec 3.6.0
  - rubocop-rspec_rails 2.31.0
  - rubocop-factory_bot 2.27.1

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