forked from phoedos/pmd
#1399 False positive for VariableNamingConventions with annotation @interface
This commit is contained in:
@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.java.rule.naming;
|
||||
|
||||
import net.sourceforge.pmd.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
|
||||
@ -111,9 +112,12 @@ public class VariableNamingConventionsRule extends AbstractJavaRule {
|
||||
}
|
||||
boolean isStatic = node.isStatic();
|
||||
boolean isFinal = node.isFinal();
|
||||
|
||||
Node type = node.jjtGetParent().jjtGetParent().jjtGetParent();
|
||||
// Anything from an interface is necessarily static and final
|
||||
if (node.jjtGetParent().jjtGetParent().jjtGetParent() instanceof ASTClassOrInterfaceDeclaration
|
||||
&& ((ASTClassOrInterfaceDeclaration) node.jjtGetParent().jjtGetParent().jjtGetParent()).isInterface()) {
|
||||
// Anything inside an annotation type is also static and final
|
||||
if (type instanceof ASTClassOrInterfaceDeclaration && ((ASTClassOrInterfaceDeclaration) type).isInterface()
|
||||
|| type instanceof ASTAnnotationTypeDeclaration) {
|
||||
isStatic = true;
|
||||
isFinal = true;
|
||||
}
|
||||
|
@ -355,6 +355,15 @@ public class X {
|
||||
public class X {
|
||||
private final String _projection;
|
||||
private final String _projectionID;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#1399 False positive for VariableNamingConventions with annotation @interface</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public @interface Relation {
|
||||
int NO_REVERSE_RELATION = -1;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -15,6 +15,7 @@
|
||||
* [#1370](https://sourceforge.net/p/pmd/bugs/1370/): ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
|
||||
* [#1371](https://sourceforge.net/p/pmd/bugs/1371/): InsufficientStringBufferDeclaration not detected properly on StringBuffer
|
||||
* [#1384](https://sourceforge.net/p/pmd/bugs/1384/): NullPointerException in ConsecutiveLiteralAppendsRule
|
||||
* [#1399](https://sourceforge.net/p/pmd/bugs/1399/): False positive for VariableNamingConventions with annotation @interface
|
||||
* [#1400](https://sourceforge.net/p/pmd/bugs/1400/): False positive with JUnit4TestShouldUseBeforeAnnotation
|
||||
* [#1401](https://sourceforge.net/p/pmd/bugs/1401/): False positive for StringBuilder.append called with constructor
|
||||
* [#1402](https://sourceforge.net/p/pmd/bugs/1402/): Windows-Only: File exclusions are not case insensitive
|
||||
|
Reference in New Issue
Block a user