pmd: fix #1078 Package statement introduces false positive UnnecessaryFullyQualifiedName violation

This commit is contained in:
Andreas Dangel 2013-04-05 17:11:30 +02:00
parent a6c1c1f57c
commit 4d7b4bb1bc
3 changed files with 16 additions and 1 deletions

View File

@ -25,6 +25,7 @@ Fixed bug 1073: Hard coded violation messages CommentSize
Fixed bug 1074: rule priority doesn't work on group definitions
Fixed bug 1076: Report.treeIterator() does not return all violations
Fixed bug 1077: Missing JavaDocs for Xref-Test Files
Fixed bug 1078: Package statement introduces false positive UnnecessaryFullyQualifiedName violation
Merged pull request #14: fix Nullpointer Exception when using -l jsp

View File

@ -7,6 +7,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTName;
import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
@ -42,7 +43,8 @@ public class UnnecessaryFullyQualifiedNameRule extends AbstractJavaRule {
@Override
public Object visit(ASTName node, Object data) {
if (!(node.jjtGetParent() instanceof ASTImportDeclaration)) {
if (!(node.jjtGetParent() instanceof ASTImportDeclaration)
&& !(node.jjtGetParent() instanceof ASTPackageDeclaration)) {
checkImports(node, data, true);
}
return data;

View File

@ -276,4 +276,16 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>#1078 Package statement introduces false positive UnnecessaryFullyQualifiedName violation</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
package a.b;
import a.*;
public class Test {}
]]></code>
</test-code>
</test-data>