Remove dead container

- The values were stored but never read
This commit is contained in:
Juan Martín Sotuyo Dodero
2023-01-28 14:13:30 -03:00
parent 4eaae9ab4e
commit bbd898549e

View File

@ -58,10 +58,8 @@ public class UnnecessaryImportRule extends AbstractJavaRule {
private static final String IMPORT_FROM_SAME_PACKAGE_MESSAGE = "Unnecessary import from the current package ''{0}''"; private static final String IMPORT_FROM_SAME_PACKAGE_MESSAGE = "Unnecessary import from the current package ''{0}''";
private static final String IMPORT_FROM_JAVA_LANG_MESSAGE = "Unnecessary import from the java.lang package ''{0}''"; private static final String IMPORT_FROM_JAVA_LANG_MESSAGE = "Unnecessary import from the java.lang package ''{0}''";
private final Set<ImportWrapper> staticImports = new HashSet<>();
private final Set<ImportWrapper> allSingleNameImports = new HashSet<>(); private final Set<ImportWrapper> allSingleNameImports = new HashSet<>();
private final Set<ImportWrapper> allImportsOnDemand = new HashSet<>(); private final Set<ImportWrapper> allImportsOnDemand = new HashSet<>();
private final Set<ImportWrapper> staticImportsOnDemand = new HashSet<>();
private final Set<ImportWrapper> unnecessaryJavaLangImports = new HashSet<>(); private final Set<ImportWrapper> unnecessaryJavaLangImports = new HashSet<>();
private final Set<ImportWrapper> unnecessaryImportsFromSamePackage = new HashSet<>(); private final Set<ImportWrapper> unnecessaryImportsFromSamePackage = new HashSet<>();
@ -101,8 +99,6 @@ public class UnnecessaryImportRule extends AbstractJavaRule {
@Override @Override
public Object visit(ASTCompilationUnit node, Object data) { public Object visit(ASTCompilationUnit node, Object data) {
this.allSingleNameImports.clear(); this.allSingleNameImports.clear();
this.staticImports.clear();
this.staticImportsOnDemand.clear();
this.allImportsOnDemand.clear(); this.allImportsOnDemand.clear();
this.unnecessaryJavaLangImports.clear(); this.unnecessaryJavaLangImports.clear();
this.unnecessaryImportsFromSamePackage.clear(); this.unnecessaryImportsFromSamePackage.clear();
@ -214,12 +210,6 @@ public class UnnecessaryImportRule extends AbstractJavaRule {
// duplicate // duplicate
reportWithMessage(node, data, DUPLICATE_IMPORT_MESSAGE); reportWithMessage(node, data, DUPLICATE_IMPORT_MESSAGE);
} }
if (node.isStatic()) {
container = node.isImportOnDemand() ? staticImportsOnDemand
: staticImports;
container.add(new ImportWrapper(node));
}
} }
private void reportWithMessage(ASTImportDeclaration node, Object data, String message) { private void reportWithMessage(ASTImportDeclaration node, Object data, String message) {