- Version: 7.9.4 (build 35981)
When using Java 11 and a switch statement with enums SQ forces the adding of a default which because the switch is enum driven is unreachable. Because it is unreachable it can’t be tested and the code is consequently marked as uncovered.
Is there a current option to turn this off for this case? If not, is there a possibility of adding a way of turning of forcing defaults when you use an enum in Java 11 switches?
public enum OPERATION {CREATE, MERGE, DELETE}
public void doOperation(final OPERATION operation) {
switch (operation) {
case CREATE:
System.out.println("CREATE called");
break;
case MERGE:
System.out.println("MERGE called");
break;
case DELETE:
System.out.println("DELETE called");
break;
default:
System.out.println(
"SQ forces default to be added and this code is unreachable but is marked as untested code");
}
}
doOperation(OPERATION.CREATE);