Use of concrete class
Reports usages of concrete classes, rather than interfaces. Such declarations may represent a failure of abstraction and may make testing more difficult.
Declarations whose classes come from system or third-party libraries will not be reported by this inspection. Casts, instanceofs, and local variables are not reported in equals() method implementations. Also, casts are not reported in clone() method implementations.
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.
UseOfConcreteClass- 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.
Use the Ignore abstract class type option to ignore casts to abstract classes.
Use the subsequent options to control contexts where the problem is reported.
Inspection ID: UseOfConcreteClass
Inspection options
Here you can find the description of settings available for the Use of concrete class inspection, and the reference of their default values.
- Ignore abstract class type
Option ID:
ignoreAbstractClassesDefault value:
Not selected- Ignore Java records
Option ID:
ignoreRecordsDefault value:
Selected- Report method return type
Option ID:
reportMethodReturnsDefault value:
Selected- Report method parameter type
Option ID:
reportMethodParametersDefault value:
Selected- Report local variable type
Option ID:
reportLocalVariablesDefault value:
Selected- Report static field type
Option ID:
reportStaticFieldsDefault value:
Selected- Report instance field type
Option ID:
reportInstanceFieldsDefault value:
Selected- Report type used in instanceof, patterns, or getClass() comparison
Option ID:
reportInstanceOfDefault value:
Selected- Report type used in cast expression
Option ID:
reportCastDefault 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: |