A function takes more parameters than the configured maximum
What it finds
A call with many arguments is hard to read and easy to get wrong: arguments of the same type can be swapped without the compiler noticing, and every new option changes every caller. A struct of options, or splitting the function, keeps calls readable.
Every declared parameter counts, named or not, and the receiver of a method does not. Function literals are not checked, since their signatures are often fixed by what they are passed to. The maximum is the parameter max_parameters, 7 by default.
From the rule's source, long_parameter_list.rs.
package p func open(name string, flag, perm, size, mode, owner, group, retries int) error { return nil }tx0 reports: open takes 8 parameters, more than 7 func fine(a, b, c, d, e, f, g int) {} func unnamed(int, int, int, int, int, int, int, string) {}tx0 reports: unnamed takes 8 parameters, more than 7 Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:long-parameter-list" = "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:long-parameter-list] reason="..."tx0 explain tx0/go:long-parameter-list shows the same in the terminal. Found a false positive? Report it.