InspectionGadgets: erroneous error reported for update in for loop

IG erroneously reports an error if one performs an indexed update using a variable other than the loop variable, even if the variable in question is actually being updated within the loop.

For example:

int j = 0;
for (Iterator i = txs.keySet().iterator(); i.hasNext(); j++)
txIds[j] = (String)i.next();

Erroneously reports the error: "for statement has update which does not use the for loop variable", despite the fact that j is being incremented on each iteration.

1 comment


While this case is not an error, I don't see any way to weaken the inspection so that it reports the legitimate errors it finds and doesn't report this. Any ideas on how to separate out this case?

--Dave Griffith

0

Please sign in to leave a comment.