Reports constructors whose number of parameters exceeds the specified maximum.
Such objects are hard to instantiate, especially if some parameters are optional.
Constructors with too many parameters may indicate that refactoring is necessary.
Consider applying the builder pattern, for example.
Example:
public BankAccount(long accountNumber,
String owner,
double balance,
double interestRate) {
// fields initialization
}
Configure the inspection:
- Use the Parameter limit field to specify the maximum allowed number of parameters in a constructor.
- Use the Ignore constructors with visibility list to specify whether the inspection should ignore constructors with specific visibility.