An imported name is not used in the file

tx0/java:unused-importrecommendedwarningstyle

What it finds

An import whose name the file never uses adds a dependency the code does not have, and leaves readers looking for where it is needed.

A single-type or single-static import counts as used when its simple name appears as an identifier anywhere outside the imports, or as a word in a documentation comment, where links such as {@link Foo} refer to it. Imports on demand (.*) are left alone. The fix removes the import.

From the rule's source, unused_import.rs.

Example from the rule's tests
import java.util.List;import java.util.Map;tx0 reports: java.util.Map is imported but not usedimport java.util.Set;import java.util.concurrent.*;import static java.lang.Math.max;import static java.lang.Math.min;tx0 reports: java.lang.Math.min is imported but not used /** Keeps a {@link Set} of names. */class Names {  List<String> names;  int top(int a, int b) {    return max(a, b);  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:unused-import" = "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:unused-import] reason="..."

tx0 explain tx0/java:unused-import shows the same in the terminal. Found a false positive? Report it.