Class UnnecessaryImportRule

  • All Implemented Interfaces:
    AstVisitor<Object,​Object>, JavaParserVisitor, JavaVisitor<Object,​Object>, PropertySource, Rule

    public class UnnecessaryImportRule
    extends AbstractJavaRule
    Detects unnecessary imports.

    For PMD 7 I had hoped this rule could be rewritten to use the symbol table implementation directly instead of reimplementing a symbol table (with less care). This would be good for performance and correctness. Modifying the symbol table chain to track which import is used is hard though, mostly because the API to expose is unclear (we wouldn't want symbol tables to expose a mutable API).