SKY-C303 · Quality, structure and performance
Too many arguments
A function that takes many positional parameters is easy to call with two values swapped. SKY-C303 reports a Python function with more than 5 required positional parameters or more than 10 parameters in all, and a TypeScript, JavaScript, Java or Go function with more than 5 parameters.
- Languages
- Python, TypeScript, JavaScript, Java, Go
- Quality gate
- counted toward the gate limits (full and diff scans). Advice that is measured on every
--qualityscan but not listed by default. It is listed, and counted towardmax_quality, with--all-adviceor when the rule is named in[tool.skylos.gate] rules. - Finding type
- advice
- Catalog name
- Too many function arguments
Why it matters
create_invoice(42, 99.0, "EUR", today, 0.2, 30) runs without error when the tax rate and the due days trade places, and the customer gets a bill due in a fraction of a day with a 3000% tax. Long parameter lists also tend to grow, because each new option is one more slot.
What Skylos flags
"""Invoice creation for the billing service.""" from datetime import timedelta def create_invoice(customer_id, amount, currency, issued_on, due_days, tax_rate): due_date = issued_on + timedelta(days=due_days) return { "customer_id": customer_id, "currency": currency, "due_date": due_date.isoformat(), "total": round(amount * (1 + tax_rate), 2), }What Skylos leaves alone
"""Postal addresses kept on customer accounts.""" class Address: def __init__(self, street, city, region, postcode, country, phone): self.street = street self.city = city self.region = region self.postcode = postcode self.country = country self.phone = phoneWhy Skylos leaves it alone
The constructor takes six required values, but it only stores each one in a field of the same kind of plain record class. Skylos treats that as a record, whose parameters name its fields, and does not report it.
More languages
TypeScript
Flagged
export function sendInvoice( to: string, subject: string, body: string, cc: string[], replyTo: string, attachPdf: boolean,): void { console.log(to, subject, body, cc, replyTo, attachPdf);}Not flagged
type SendOptions = { to: string; subject: string; body: string; cc: string[]; replyTo: string; attachPdf: boolean;}; export function sendInvoice(options: SendOptions): void { const { to, subject, body, cc, replyTo, attachPdf } = options; console.log(to, subject, body, cc, replyTo, attachPdf);}Why Skylos leaves it alone
The six values arrive as one options object, so callers name each one. TS/JS counts the entries between the parentheses, and an object parameter (destructured or not) is one entry.
How Skylos decides
- Runs with
--quality. Python counts the positional parameters without a default, leaving outselforclsof a method, and separately the total of positional and keyword-only parameters.*argsand**kwargsare not counted. - Python reports MEDIUM when the required positional count is above
max_argsunder[tool.skylos](default 5), and otherwise LOW when the total is above 10. Parameters after*count only toward the total. - Python leaves alone a Click command whose every parameter is declared by a
@click.optionor@click.argument, the__init__of a plain class that only copies each parameter into a field of the same object, wide keyword-only options that are all passed on to one dataclass of the same module, and@overloaddeclarations in.pyistubs that are only wide in total. A function with@overloadsignatures is reported once, on its implementation, for its widest signature. - Python skips test code (test folders,
test_*.pyand*_test.pymodules that define tests, files pytest is configured to collect),examplesandbenchmarksfolders, a top-leveldocsfolder and the rootsetup.py. - TypeScript and JavaScript count every entry in the parameter list, Java every formal parameter, and Go every parameter name. They report LOW above 5; the limit there is fixed and does not read
max_args. - Reports on the
def(or function) line.
How to fix it
Make the options keyword-only with a *, so every caller has to name them, or group values that travel together into one object. In TS/JS, pass an options object.
"""Invoice creation for the billing service.""" from datetime import timedelta Removed: def create_invoice(customer_id, amount, currency, issued_on, due_days, tax_rate):Added: def create_invoice(customer_id, amount, *, currency, issued_on, due_days, tax_rate): due_date = issued_on + timedelta(days=due_days) return { "customer_id": customer_id, "currency": currency, "due_date": due_date.isoformat(), "total": round(amount * (1 + tax_rate), 2), }When it can be wrong
- A callback whose signature is fixed by a framework or a protocol, such as a handler that must take six positional values, is still reported unless it matches one of the exemptions above.
- In TS/JS, Java and Go the limit cannot be changed, and a parameter with a default value counts like any other.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
On the
defline (the reported line), which can be split so the comment fits:Python def create_invoice( # skylos: ignore[SKY-C303] public API, kept for callers customer_id, amount, currency, issued_on, due_days, tax_rate):[tool.skylos] ignore = ["SKY-C303"]turns the rule off for the project;max_args = 7under[tool.skylos]raises the Python limit instead. A baseline accepts existing findings, but it records the absolute file path and the line, so an entry stops matching when the checkout moves or the line shifts.