Ruby

Ruby

Made by DeepSource

Unused assignment detected RB-LI1078

Bug risk
Minor
Autofix

Unused assignments are unnecessary and can be removed. In case the declaration is intentional, you can prefix _ before the variable name.

This issue is autofixable, and the behavior of the autofix is tweakable by using the FixType switch, which accepts either of Replace or Remove. The default is to remove the unused assignment.

Bad practice

# Lint/UselessAssignment:
#   FixType: Remove

def some_method
  some_var = 1
  do_something
end

Recommended

# Lint/UselessAssignment:
#   FixType: Remove

def some_method
  do_something
end

Bad practice

# Lint/UselessAssignment:
#   FixType: Replace

def some_method
  some_var = 1
  do_something
end

Recommended

# Lint/UselessAssignment:
#   FixType: Replace

def some_method
  _some_var = 1
  do_something
end