IG: 'for" loop replaceable by 'for each'
My for loops are often marked with warnings because they are using an iterator explicitly instead of using the for each construct. However, in the use-cases where the iterator is being referenced (either i.remove() or i.hasNext() to see if you're on the last iteration of the loop) it is not possible to convert the code to a 'for each' and in fact the inspection converts the code such that it will no longer compile (since of course the code still references the now non-existant iterator). First, I think this is probably a bug and the iterator should be checked first for usage of remove() and hasNext() inside of the loop body. Second, (and if that is a difficult issue to resolve) it would be nice if certain inspections could be classified as non-warning but not actually disabled. (I would have to know about the inspection and place my cursor on the "for" keyword and press alt-enter to explicitly invoke the inspection.) I understand inspection warning levels will be introduced but am unsure if that will resolve this problem.
I'm sorry if this has already been mentioned, but I didn't see it anywhere.
Please sign in to leave a comment.
Kirk,
you may safely submit bugs and suggestions for IG and IPP to http://www.jetbrains.net/jira/browse/IDEA
Dave has enough credentials to process them right there.
-
Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"
Ok, thanks. (http://www.jetbrains.net/jira/browse/IDEA-1484)