#14666·rubocop

Warn about variables that have no actual effect

Author: forthrinCreated Nov 18, 2025Updated Sep 18, 2026
Labelsenhancement

Is your feature request related to a problem? Please describe.

ruby
def foo
  prev = nil
  [1, 2, 3].each do
    puts it
    prev = it
  end
end

foo

Here, prev is of no consequence to the program, ie.

  • Not used for decision-making
  • Not copied to other variables
  • Not sent to other functions
  • Not printed to the terminal
  • Not available outside its scope

Describe the solution you'd like

Variable `prev` has no actual effect and can be removed [[Correctable] Lint/InconsequentialVariable]

Describe alternatives you've considered

None come to mind.

Additional context

Nothing comes to mind.