Skip to content

max-parameters

Default severity: warning

Reports function declarations with more than eight parameters. Long parameter lists are difficult to call correctly and often reveal a missing domain type. Method receivers are not counted.

Each named parameter counts individually, including names that share a type. An unnamed parameter field counts as one.

func Open(path string, read, write, create, truncate, appendMode, sync, exclusive, temporary bool) error {
// ...
}

The example has nine parameters: path plus eight named booleans.

type OpenOptions struct {
Read bool
Write bool
Create bool
Truncate bool
AppendMode bool
}
func Open(path string, options OpenOptions) error {
// ...
}

Prefer a cohesive options or request type. Do not combine unrelated values into a struct purely to bypass the rule.

The default maximum is eight.

[checks.rules.max-parameters]
max-parameters = 10

Set max-parameters = 0 to use the built-in maximum of eight.