The default case of a switch is not its last case
What it finds
A default in the middle of the cases is easy to miss, and a reader looking for what happens to unlisted values expects it at the end.
From the rule's source, default_not_last.rs.
int pick(int n){ switch (n) { default:tx0 reports: default is not the last case of the switch return 0; case 1: return 1; }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:default-not-last" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/c:default-not-last] reason="..."tx0 explain tx0/c:default-not-last shows the same in the terminal. Found a false positive? Report it.