GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
The following code
a = 42
b = a.to_s
a = 56
Should be regarded as problematic, because of the second assignment to a which isn't used. It'd be nice if rubocop could generate a warning about it.
I proposed the following as an enhancement for MRI, but it hasn't attracted any attention yet: https://bugs.ruby-lang.org/issues/8691 . The Rubinius team isn't planning on adding this kind of thing to Rubinius itself, based on rubinius/rubinius#2054. The JRuby team isn't enthusiastic about this kind of thing, based on https://jira.codehaus.org/browse/JRUBY-6905
I think that such a check makes sense indeed. @yujinakayama Would you look into it?
Actually I wondered why MRI does not warn about it when I was implementing UnusedLocalVariable. However I was not sure if warning of it is valid at that time, so I've made the cop mimic MRI. But yes, I'll try.
Thanks for all the work you put into doing this!
It's detected several useless assignments in my application, so it's proved to be useful!