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"
}

Remediation

Group the related parameters into a case class and pass that instead, or split the method so each part takes only what it needs. Where several arguments are genuinely optional configuration, a single options case class with defaults reads better than six positional parameters.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved