179 }
180
181 if ((next != ArgNext.NONE) && !arg.isEmpty()) {
182 switch (next) {183 case DEFINE:184 addMacro(arg, defines);185 break;186 case INCLUDE:187 case IQUOTE:188 includes.add(makeRelativeToCwd(cwd, arg));189 break;190 case ISYSTEM:191 iSystem.add(makeRelativeToCwd(cwd, arg));192 break;193 case IDIRAFTER:194 iDirAfter.add(makeRelativeToCwd(cwd, arg));195 break;196 }197 next = ArgNext.NONE;
198 }
199 }
Switch statements that have expression of an enum type and don't have the default label must specify all the enum elements in their cases.
Even if the current state of the application doesn't require certain enum elements to be considered in switch cases, a patch in the future may change that. When this happens, and the programmer forgets to handle the additional enum elements, this will almost always result in a bug in the application. For this reason, it's highly encouraged to cover all the enum fields in cases of a switch statement.
enum Color {
RED,
BLUE
}
public void test() {
Color color = getColor();
// Bad, missing `Color::BLUE` or `default`.
switch (color) {
case RED:
paintRed();
break;
}
}
Consider specifying all the enum elements or specify a default
case.
enum Color {
RED,
BLUE
}
public void test() {
Color color = getColor();
switch (color) {
case RED:
paintRed();
break;
case BLUE:
paintBlue();
break;
}
}