Method declares six or more parameters

ID

apex.maintainability.max_params

Severity

low

Remediation Complexity

medium

Remediation Risk

medium

Remediation Effort

medium

Resource

Complexity

Language

Apex

Description

Reports a method declaring six or more parameters (fixed threshold: 6).

Rationale

Apex has no named arguments, so every call site is a bare positional list. Two parameters of the same type - two String`s, two `Id`s, a pair of `Boolean flags - can be transposed without a compile error, and the defect surfaces as wrong data rather than as a failure. A list that long is also a design signal: the method is usually doing several things, or several of the arguments always travel together and belong in a wrapper class.

The following code illustrates the pattern detected by this rule:

public class MaxParams {

    // FLAGGED: Method declares six or more parameters
    public void createInvoice(Id accountId, Date issued, Decimal amount, String currencyCode, Boolean taxed, String note) {
        System.debug(accountId);
    }

    // FLAGGED: Method declares six or more parameters
    public static String buildKey(String a, String b, String c, String d, String e, String f, String g) {
        return a + b + c + d + e + f + g;
    }

    public void updateInvoice(Id accountId, Date issued, Decimal amount, String currencyCode, Boolean taxed) {
        System.debug(accountId);
    }

    public void touch(Id accountId) {
        System.debug(accountId);
    }
}

Remediation

Group the related parameters into a small wrapper class or an sObject and pass that, or split the method so each part takes only what it needs. Where the extra arguments are optional configuration, a single options class with defaults reads better than six positional values.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved