missing-switch-default
What it does
Section titled “What it does”Reports a switch statement that has no default label.
Why it matters
Section titled “Why it matters”Without default, a value that no case names is ignored without notice, so a new enum constant or an unexpected input falls through the switch and the program goes on with the wrong state.
To fix, add a default that handles the case or throws.
Example
Section titled “Example”... } catch (Exception e) { // ignored } switch (x) { case 1: g(); }...Configuration
Section titled “Configuration”java: lint: rules: missing-switch-default: warn # off, warn (default), errorSuppress one line with sudsy-disable-next-line missing-switch-default in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| checkstyle | MissingSwitchDefault |
full |