A public static final EnumType field in an enumeration confuses FindBugs and FindBugs will report a SF_SWITCH_NO_DEFAULT issue when all cases are covered in a switch statement.
For instance, given the following enumeration:
:::java
public enum TrafficLight {
RED, YELLOW, GREEN;
// introducing a public static final <EnumType> field introduces
// a SF_SWITCH_NO_DEFAULT bug
public static final TrafficLight GO = GREEN;
}
FindBugs will report that a default case is missing even though all enum constants are covered:
:::java
public void showBug(TrafficLight light) {
// default case is missing, but all cases are covered
switch (light) {
case RED:
System.out.println("red");
break;
case YELLOW:
System.out.println("yellow");
break;
case GREEN:
System.out.println("green");
break;
}
}
Well spotted, thanks. Fixed:
https://github.com/findbugsproject/findbugs/commit/fac4acaf8a38efb9076bd07b5d401e363865915d