Parameter hides field
Reports method parameters named identically to a field of a surrounding class. As a result of such naming, you may accidentally use the parameter when using the identically named field is intended.
A quick-fix is suggested to rename the parameter.
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.
hiding- 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.
You can configure the following options for this inspection:
Ignore for property setters - ignore parameters of simple setters.
Ignore superclass fields not visible from subclass - ignore
privatefields in a superclass, which are not visible from the method.Ignore for constructors - ignore parameters of constructors.
Ignore for abstract methods - ignore parameters of abstract methods.
Ignore for static method parameters hiding instance fields - ignore parameters of
staticmethods hiding an instance field and to ignore parameters of instance methods in static inner classes hiding an instance field of an outer class. While not strictly hiding, such parameters can still be confusing.
Inspection options
Here you can find the description of settings available for the Parameter hides field inspection, and the reference of their default values.
- Ignore for property setters
Default value:
Not selected- Ignore superclass fields not visible from subclass
Default value:
Selected- Ignore for constructors
Default value:
Not selected- Ignore for abstract methods
Default value:
Not selected- Ignore for static method parameters hiding instance fields
Default value:
Selected
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: |