unused-import
What it does
Section titled “What it does”Reports an import whose name the file does not use. Imports with * are not checked, and a name in a doc comment counts as a use where the language has doc comments. No fix: removing an import can change which declaration a name means.
Why it matters
Section titled “Why it matters”An import that nothing uses is dead code. It misleads the reader about what the file depends on, and where an import runs the module, as in Python, it still costs the time to load it and fails where the module is not installed.
To fix, remove the import.
Example
Section titled “Example”import java.util.List;import java.util.Map;import java.util.Set;import java.io.*;import static java.lang.Math.max;import static java.lang.Math.min;
/** Uses {@link Set}. */class A {...Configuration
Section titled “Configuration”java: lint: rules: unused-import: warn # off (default), warn, errorkotlin: lint: rules: unused-import: warn # off (default), warn, errorpython: lint: rules: unused-import: warn # off (default), warn, errorEnabled by the presets: kotlin/ktlint, python/ruff.
Suppress one line with sudsy-disable-next-line unused-import in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| checkstyle | UnusedImports |
partial | Names in Javadoc count as used; no option to turn that off. |
| ktlint | no-unused-imports |
full | |
| ruff | F401 |
full |