A switch has more cases than the configured maximum

tx0/go:large-switchstrictwarningmaintainability

What it finds

A switch with dozens of cases is a table written as code: it is long to read, each new value means another case, and cases that share behavior are easy to let drift apart. A map from values to data or functions often says the same more compactly.

Expression and type switches are checked, and each case clause counts, default included. The maximum is the parameter max_cases, 30 by default.

From the rule's source, large_switch.rs.

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:

tx0.toml
[rules]
"tx0/go:large-switch" = "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/go:large-switch] reason="..."

tx0 explain tx0/go:large-switch shows the same in the terminal. Found a false positive? Report it.