Skip to main content

SKY-C303 · Quality, structure and performance

Too many arguments

Varies

The catalog gives no severity. Python reports MEDIUM when a function has more required positional parameters than the limit and LOW when only the total number of parameters is over 10. TypeScript, JavaScript, Java and Go always report LOW.

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 --quality scan but not listed by default. It is listed, and counted toward max_quality, with --all-advice or when the rule is named in [tool.skylos.gate] rules.
Finding type
advice
Catalog name
Too many function arguments
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

app/billing.py · PythonReported on line 6
"""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

app/addresses.py · Python
"""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 = phone

Why 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

src/mail/invoice.ts · TypeScriptReported on line 1
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

src/mail/invoice.ts · TypeScript
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

  1. Runs with --quality. Python counts the positional parameters without a default, leaving out self or cls of a method, and separately the total of positional and keyword-only parameters. *args and **kwargs are not counted.
  2. Python reports MEDIUM when the required positional count is above max_args under [tool.skylos] (default 5), and otherwise LOW when the total is above 10. Parameters after * count only toward the total.
  3. Python leaves alone a Click command whose every parameter is declared by a @click.option or @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 @overload declarations in .pyi stubs that are only wide in total. A function with @overload signatures is reported once, on its implementation, for its widest signature.
  4. Python skips test code (test folders, test_*.py and *_test.py modules that define tests, files pytest is configured to collect), examples and benchmarks folders, a top-level docs folder and the root setup.py.
  5. 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.
  6. 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.

app/billing.py · Python · the fix, against the flagged file
"""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 def line (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 = 7 under [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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.