Inspectopedia Help

Method can be made 'static'

Reports methods that can safely be made static. Making methods static when possible can reduce memory consumption and improve your code quality.

A method can be static if:

  • it is not synchronized, native or abstract,

  • does not reference any of non-static methods and non-static fields from the containing class,

  • is not an override and is not overridden in a subclass.

Use the following options to configure the inspection:

  • Whether to report only private and final methods, which increases the performance of this inspection.

  • Whether to ignore empty methods.

  • Whether to ignore default methods in interface when using Java 8 or higher.

  • Whether to let the quick-fix replace instance qualifiers with class references in calls to methods which are made static, that is, call myClass.m() would be replaced with MyClass.m().

Inspection options

Option

Type

Default

Only check 'private' or 'final' methods

Checkbox

false

Ignore empty methods

Checkbox

true

Ignore 'default' methods

Checkbox

true

Quick-fix replaces instance qualifiers with class references

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023