Community
Participate
Working Groups
for(c: s.toCharArray) { } I'd expect a warning like 'The value of 'c' is never used'
This should wait until we have configurable severities.
Also applies to switch parameters. Pushed to review.
A quick offline discussion revealed the following thoughts: A 'for' loop doesn't leave the user the option to declare a variable or not. So in case you want to iterate and don't use the variable you cannot easily get rid of the warning. Support for @SuppressWarnings would help but still it is questionable which practical programming problems could be revealed by this. Generally speaking the validation of the foreach-loop var seems to be more similar to the 'unused parameters' validation when implementing methods as the regular 'unsed local vars' validation. Therefore we decided to not have that warning, at least until we have full support for @SuppressWarnings. But still we should do it for 'switch' and 'traditional for' as there you have the choice.
+1 Unused locals in for-each and catch clauses deserve an own issue code with the same message. The preference page should have a checkbox like 'also mark in for-each loops and ..'. Without SuppressWarnings it's not too useful, though.
Pushed changes for switch only.