bbatsov/rubocop — pull request #469 by yujinakayama (2013-09-08 15:15:21+00:00)
Title: Track usage of every assignment in UnusedLocalVariable

This closes #458.

It was much more complex than I expected, but I think I've done. :) `UnusedLocalVariable` now tracks usage of every assignment, that is neither entire variable lifetime nor only last assignment.

Before merging, I think we should consider reorganizing the new `UnusedLocalVariable` and `UselessAssignment`.

* About local variable assignments, `UnusedLocalVariable` is now superior to `UselessAssignment`.
* `UnusedLocalVariable` tracks every useless assignment in every scope.
* `UselessAssignment` tracks useless assignment at the end of method.
* `UselessAssignment` also tracks useless setter call at the end of method (technically it's not assignment though).

I think there are two choices:

1. Merge the two cops into `UselessAssignment`. Two different logics, the new `UnusedLocalVariable`'s one and the setter call tracking part of the current `UselessAssignment`, would live in a cop.
2. Extract the setter call tracking logic to `UselessSetterCall` (or something), and rename `UnusedLocalVariable` to `UselessAssignment`.

I'd prefer the 2.