Feature #8691

Add warning for variable that is re-assigned but not re-used

Added by Andrew Grimm 9 months ago. Updated 7 months ago.

[ruby-core:56184]
Status:Closed
Priority:Normal
Assignee:-
Category:-
Target version:-

Description

The following code

def reassignedunused
a = 42
b = a.to
s
a = 56
b
end

Does not currently generate an "assigned but unused variable" warning about the second assignment to "a".

Is it feasible to create a warning for such a scenario?

History

#1 Updated by Andrew Grimm 7 months ago

A third party tool that I use, called Rubocop, has implemented such functionality. https://github.com/bbatsov/rubocop/issues/458

So I don't really require this functionality in MRI any more.

#2 Updated by Zachary Scott 7 months ago

  • Status changed from Open to Feedback

@andrew should we close this ticket then?

#3 Updated by Andrew Grimm 7 months ago

Yes, close the ticket. If someone else wants the functionality, or has implemented the functionality and wants to submit a patch, they can open another ticket.

#4 Updated by Zachary Scott 7 months ago

  • Status changed from Feedback to Closed

closing, see ruby-core:57091

Also available in: Atom PDF