Method can be made 'void'
Reports methods whose return values are never used when called. The return type of such methods can be made void
.
Methods annotated with Error Prone's or AssertJ's @CanIgnoreReturnValue
annotation will not be reported. The quick-fix updates the method signature and removes return
statements from inside the method.
Example:
After the quick-fix is applied to both methods:
NOTE: Some methods might not be reported during in-editor highlighting due to performance reasons. To see all results, run the inspection using Code | Inspect Code or Code | Analyze Code | Run Inspection by Name>
Use the Ignore chainable methods option to ignore unused return values from chainable calls.
Use the Maximal reported method visibility option to control the maximum visibility of methods to be reported.
Inspection options
Option | Type | Default |
---|---|---|
Ignore chainable methods | Checkbox | false |
Maximal method visibility | Dropdown | public |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |