resources.report.rules.pmd.SwitchStmtsShouldHaveDefault.html Maven / Gradle / Ivy
SwitchStmtsShouldHaveDefault
SwitchStmtsShouldHaveDefault
All switch statements should include a default option to catch any unspecified values.
//SwitchStatement[not(SwitchLabel[@Default='true'])]
Example(s):
public void bar() {
int x = 2;
switch (x) {
case 1: int j = 6;
case 2: int j = 8;
// missing default: here
}
}