Too many parameters
This is how the comment reads inline, under the flagged line.
Why it matters
Long positional parameter lists are easy to call in the wrong order and hard to extend.
What to do
Group related values into an object or dataclass, or pass keyword arguments.
Examples
function send(to, from, subject, body, cc, bcc, replyTo) {}function send(msg: Message) {}What it catches
It reads the shape of the code: functions, blocks, loops and calls. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
function f(a, b, c, d, e, g) {
return a;
}
src/app.py
def f(a, b, c, d, e, g):
return a
Left alone
function f({ a, b, c, d, e, g }) {
return a;
}
src/app.py
def f(a, *, b, c, d, e, g):
return a
Research
Long parameter lists. Calls are hard to read and hard to change.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"many-params"
],
"severity": {
"many-params": "medium"
}
}
}
ftakes 6 parameters. Callers have to remember their order.