Unnecessarily qualified static access
Reports usages of static members qualified with the class name.
Such qualification is unnecessary and may be safely removed.
Example:
After the quick-fix is applied:
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
Option | Type | Default |
---|---|---|
Ignore unnecessarily qualified field accesses | Checkbox | false |
Ignore unnecessarily qualified method calls | Checkbox | false |
Only report qualified static access from a static context | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |