A static member of a class of this file is reached through a variable, as if it belonged to the object

tx0/java:static-access-via-instancerecommendedwarningmaintainability/designdepth fastsmell

What it finds

counter.total and task.create() read as if they used the object in the variable, but a static member belongs to the class: the variable's value plays no part and may even be null. Writing the class name says so.

Reported is a field access or call through a variable whose declared type is a class of this file, of a member that class declares static. The fix writes the class name.

From the rule's source, static_access_via_instance.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:static-access-via-instance" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:static-access-via-instance] reason="..."

tx0 explain tx0/java:static-access-via-instance shows the same in the terminal. Found a false positive? Report it.