Inspectopedia 2025.3 Help

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:

// reported if visibility setting is Protected or Public protected String myToUpperCase(String s) { return s.toUpperCase(); } // simple setter, reporting depends on setting public String setStr(String str) { myStr = str; return myStr; } void test() { setStr("value"); // return value is unused myToUpperCase("result"); // return value is unused }

After the quick-fix is applied to both methods:

protected void myToUpperCase(String s) { // 'return' removed completely // as 's.toUpperCase()' has no side effect } public void setStr(String str) { myStr = str; // 'return' removed } ...

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 >

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.

UnusedReturnValue
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.

Settings or Preferences | Editor | Inspections | Java | Declaration redundancy

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 ID: UnusedReturnValue

Inspection options

Here you can find the description of settings available for the Method can be made 'void' inspection, and the reference of their default values.

Ignore chainable methods

Option ID:

IGNORE_BUILDER_PATTERN

Default value:

Not selected
Maximal method visibility

Option ID:

highestModifier

Default value:

public

Other available settings:

  • 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:

//noinspection UnusedReturnValue

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:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025