Method declares 6 or more parameters
ID |
scala.maintainability.max_params |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Complexity |
Language |
Scala |
Description
Reports a def whose parameter list holds six or more parameters. The threshold is fixed at six: the pattern names six typed parameters followed by an ellipsis, so longer lists match too.
Rationale
A long parameter list is hard to call correctly - adjacent parameters of the same type can be swapped silently, and every caller has to remember the order. It is also a reliable signal that the method carries more than one responsibility, or that a group of the arguments really belongs together as a value of its own.
The following code illustrates the pattern detected by this rule:
class MaxParams {
// FLAGGED: Method declares 6 or more parameters
def render(id: Long, name: String, width: Int, height: Int, scale: Double, alpha: Float): String =
s"$id$name"
}