forked from phoedos/pmd
Recent change in UseSingleton introduced a false + for methods with annotations
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6802 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
240e548c36
commit
9b4b50560d
@ -163,6 +163,20 @@ public enum EnumTest {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(EnumTest.A);
|
System.out.println(EnumTest.A);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
OK, method annotations
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
public Foo() { }
|
||||||
|
@Override
|
||||||
|
public void doSomething() { }
|
||||||
|
public static void main(String args[]) { }
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package net.sourceforge.pmd.rules.design;
|
package net.sourceforge.pmd.rules.design;
|
||||||
|
|
||||||
import net.sourceforge.pmd.AbstractRule;
|
import net.sourceforge.pmd.AbstractRule;
|
||||||
|
import net.sourceforge.pmd.ast.ASTAnnotation;
|
||||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceBody;
|
import net.sourceforge.pmd.ast.ASTClassOrInterfaceBody;
|
||||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
||||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
|
import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
|
||||||
@ -26,11 +27,14 @@ public class UseSingleton extends AbstractRule {
|
|||||||
int methodCount = 0;
|
int methodCount = 0;
|
||||||
boolean isOK = false;
|
boolean isOK = false;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
Node n = decl.jjtGetChild(--i);
|
Node p = decl.jjtGetChild(--i);
|
||||||
if (n.jjtGetNumChildren() != 1) {
|
if (p.jjtGetNumChildren() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
n = n.jjtGetChild(0);
|
Node n = p.jjtGetChild(0);
|
||||||
|
if (n instanceof ASTAnnotation) {
|
||||||
|
n = p.jjtGetChild(1);
|
||||||
|
}
|
||||||
if (n instanceof ASTFieldDeclaration) {
|
if (n instanceof ASTFieldDeclaration) {
|
||||||
if (!((ASTFieldDeclaration) n).isStatic()) {
|
if (!((ASTFieldDeclaration) n).isStatic()) {
|
||||||
isOK = true;
|
isOK = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user