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:
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 options
Option | Type | Default |
---|---|---|
Ignore abstract class type | Checkbox | false |
Ignore Java records | Checkbox | true |
Report method return type | Checkbox | true |
Report method parameter type | Checkbox | true |
Report local variable type | Checkbox | true |
Report static field type | Checkbox | true |
Report instance field type | Checkbox | true |
Report type used in instanceof, patterns, or getClass() comparison | Checkbox | true |
Report type used in cast expression | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |