Community
Participate
Working Groups
Build Identifier: 20100218-1602 The description for this rules reads "When enabled, the compiler will issue an error or a warning whenever it encounters a switch case without a 'break' statement. Empty switch cases are allowed." I have created similar with a PMD rule, but it seems that it is not just a break that should be allowed in a case. A case should be able to have a final statement of a continue (explicit intent to fall through), return or throw (which would also not create an inadvertent fall through). It would be nice if this rule were expanded for these conditions. Reproducible: Always
I don't see what you expect from us. Updating the description ? If you have a return, throw or continue, the next statement is not reachable so it is not a fallthrough case. Did I misunderstand something ?
I guess from the description, it was not clear until I tried it that the 'break' as mentioned in the description was inclusive of a case exiting due to return or throw conditions vs just specifically a break statement. So I guess the rule does cover this condition and maybe the documentation could be more inclusive of this. Also, did not realize until I just tested it that continue is not allowed in a switch case construct. I was taking the word of a co-worker on this :-)
You can use continue to a label depending on the context. So you expect the description to be improved ?
Yes, I'm suggesting to clarify the description. I understand your point on continue also is the switch happens to be in a loop.
Hi Daniel, > The description for this rules reads "When enabled, the compiler will issue an > error or a warning whenever it encounters a switch case without a 'break' > statement. Empty switch cases are allowed." Are you referring to the description found in: org.eclipse.jdt.doc.user/reference/preferences/java/compiler/ref-preferences-errors-warnings.htm ? In the help, I also found this in JDT/Core options: "When enabled, the compiler will issue an error or a warning when a case may be entered by falling through a preceding, non empty case." That seems to be better, doesn't it ?
(In reply to comment #5) Yes, I like that.
Released for 3.7M1 and 3.6.1.
Created attachment 174651 [details] Proposed fix
Verified in M20100825-0800.