Inspectopedia 2025.2 Help

Unnecessarily qualified static access

Reports usages of static members unnecessarily qualified with the class name.

Qualification with the class is unnecessary when the static member is available in a surrounding class or in a super class of a surrounding class. Such qualification may be safely removed.

Example:

class Foo { static void foo() {} static int x; void bar() { Foo.foo(); System.out.println(Foo.x); } static void baz() { Foo.foo(); } }

After the quick-fix is applied:

class Foo { static void foo() {} static int x; void bar() { foo(); System.out.println(x); } static void baz() { foo(); } }

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.

UnnecessarilyQualifiedStaticUsage
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 | Code style issues

Use the inspection options to toggle the reporting for:

  • Static fields access:

    void bar() { System.out.println(Foo.x); }

  • Calls to static methods:

    void bar() { Foo.foo(); }

Also, you can configure the inspection to only report static member usage in a static context. In this case, only static void baz() { Foo.foo(); } will be reported.

Inspection options

Here you can find the description of settings available for the Unnecessarily qualified static access inspection, and the reference of their default values.

Ignore unnecessarily qualified field accesses

Default value:

Not selected
Ignore unnecessarily qualified method calls

Default value:

Not selected
Only report qualified static access from a static context

Default value:

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

//noinspection UnnecessarilyQualifiedStaticUsage

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.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025