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 |
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);
}
}