Constructor with too many parameters
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:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
ConstructorWithTooManyParameters- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
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.
Inspection options
Here you can find the description of settings available for the Constructor with too many parameters inspection, and the reference of their default values.
- Parameter limit
Default value:
5- Ignore constructors with visibility
Default value:
noneOther available settings:
private
package-private & private
protected, package-private & private
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |