Max Params
ID |
go.max_params |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Complexity |
Language |
Go |
Tags |
complexity |
Description
Reports a named function or method whose parameter count exceeds a configurable threshold
(default 7). Grouped parameters (a, b int) count once per name, and the method receiver is
not counted.
Rationale
A long parameter list is hard to call correctly: the argument order is easy to get wrong at the call site, and the sheer count is a strong signal that the function has accumulated several unrelated responsibilities. Grouping cohesive parameters into a small struct, or splitting the function, makes both the signature and the call sites easier to read and to change.
// FLAW — eight parameters, hard to call and likely doing too much
func buildReport(title, from, to, format, author, footer, watermark, locale string) {
// ...
}
// OK — related options grouped into a single struct
func buildReport(options ReportOptions) {
// ...
}
Remediation
Group related parameters into a dedicated struct, or split the function into smaller functions
each with a focused, short parameter list. Adjust the maxParams property if your project
standard differs from the default.