Skip to content

UnnecessaryImport removes star import from same package #553

@jhonnen

Description

@jhonnen

Given the following class

package some.pkg;

import static some.pkg.ImportedClass.*;

class SomeClass {
}

The UnnecessaryImport mutator removes the star import. The cause is a subtle bug in

var imp = i.getNameAsString();
if (packageName.isEmpty()) {
return !imp.contains(".");
}
return imp.startsWith(packageName) && imp.lastIndexOf('.') <= packageName.length();

getNameAsString() for that ImportDeclaration returns some.pkg.ImportedClass and not some.pkg.ImportedClass.* as one could expect. Therefore the import is removed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions