(maint) Enable rubocop checking for shadowed variables

Previously, we allowed variables to be shadowed by variables
of the same name at local scope. This can make for confusing
reading to someone new to the code (and can potentially indicate
logic errors).

So this commit enables rubocop checking for shadow variables. It
also fixes (by renaming) all extant shadowed variables. Naming
is hard, but a best effort was made.
This was the outer `k`, shadowed by the one at line 102. In this case I renamed the outer one, so that the inner one (all a one-liner) used the shortest variable name.