You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] UnnecessaryLocalBeforeReturn: ClassCastException in switch case with local variable returned #219
Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex]. If not specific to a language, you can use [core]
Rule Set:
UnnecessaryLocalBeforeReturn
Description:
java.lang.ClassCastException: net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement cannot be cast to net.sourceforge.pmd.lang.java.ast.ASTBlock
at net.sourceforge.pmd.lang.java.rule.design.UnnecessaryLocalBeforeReturnRule.hasAssertStatement(UnnecessaryLocalBeforeReturnRule.java:101)
at net.sourceforge.pmd.lang.java.rule.design.UnnecessaryLocalBeforeReturnRule.visit(UnnecessaryLocalBeforeReturnRule.java:52)
Code Sample demonstrating the issue:
public static int m() {
switch (0) {
default:
int i = 0;
return i;
}
}
changed the title [-][java] 5.5.3, ClassCastException in switch case with local variable returned[/-][+][java] UnnecessaryLocalBeforeReturn: ClassCastException in switch case with local variable returned[/+]on Jan 30, 2017
Activity
jsotuyod commentedon Jan 30, 2017
I confirm this is a regression, I just submitted a PR to fix it.
Thanks for the report!
adangel commentedon Jan 30, 2017
Thanks for reporting, and @jsotuyod thanks for fixing. Was probably my bad in fixing https://sourceforge.net/p/pmd/bugs/1495/...
[-][java] 5.5.3, ClassCastException in switch case with local variable returned[/-][+][java] UnnecessaryLocalBeforeReturn: ClassCastException in switch case with local variable returned[/+][java] Fix ClassCastException in UnnecessaryLocalBeforeReturn
Update changelog, fixes #219