Checkstyle
This commit is contained in:
@ -20,7 +20,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
/**
|
||||
* Helper class to analyze {@link ASTImportDeclaration}s.
|
||||
*/
|
||||
public class ImportWrapper {
|
||||
public final class ImportWrapper {
|
||||
private static final Logger LOG = Logger.getLogger(ImportWrapper.class.getName());
|
||||
|
||||
private final ASTImportDeclaration node;
|
||||
|
@ -228,7 +228,8 @@ public class UnusedImportsRule extends AbstractJavaRule {
|
||||
private void removeReferenceSingleImport(String referenceName) {
|
||||
int firstDot = referenceName.indexOf('.');
|
||||
String expectedImport = firstDot < 0 ? referenceName : referenceName.substring(0, firstDot);
|
||||
for (Iterator<ImportWrapper> iterator = imports.iterator(); iterator.hasNext(); ) {
|
||||
Iterator<ImportWrapper> iterator = imports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ImportWrapper anImport = iterator.next();
|
||||
if (!anImport.isOnDemand() && anImport.getName().equals(expectedImport)) {
|
||||
iterator.remove();
|
||||
@ -237,7 +238,8 @@ public class UnusedImportsRule extends AbstractJavaRule {
|
||||
}
|
||||
|
||||
private void removeOnDemandForPackageName(String fullName) {
|
||||
for (Iterator<ImportWrapper> iterator = imports.iterator(); iterator.hasNext(); ) {
|
||||
Iterator<ImportWrapper> iterator = imports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ImportWrapper anImport = iterator.next();
|
||||
if (anImport.isOnDemand() && anImport.getFullName().equals(fullName)) {
|
||||
iterator.remove();
|
||||
|
@ -14,6 +14,7 @@ public class UnusedImportsTest extends PmdRuleTst {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertSomething(String message, boolean condition) {
|
||||
if (!condition) {
|
||||
System.out.println(message);
|
||||
|
Reference in New Issue
Block a user