Fix for bug 2225474 - VariableNamingConventions does not work with nonprimitives
- Adding a test case to reproduce the issue ; - Fix ; - Changelog updated. Special thanks to Markus Kling for pointing this fix to me. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6807 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
e26de08062
commit
72cc961ca8
@ -7,6 +7,7 @@ Fixed bug 2338341 - ArrayIndexOutOfBoundsException in CPD (on Ruby)
|
||||
Fixed bug 2315599 - False +: UseSingleton with class containing constructor
|
||||
Fixed bug 1955852 - false positives for UnusedPrivateMethod & UnusedLocalVariable
|
||||
Fixed bug 2404700 - UseSingleton should not act on enums
|
||||
Fixed bug 2225474 - VariableNamingConventions does not work with nonprimitives
|
||||
Fixed bug - JUnitTestsShouldIncludeAssert now detects Junit 4 Assert.assert... constructs
|
||||
|
||||
October 12, 2008 - 4.2.4:
|
||||
|
@ -112,6 +112,17 @@ staticSuffix
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
static int foo_s = 42;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
False - with non primitive fields (Bug 2225474)
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class X {
|
||||
public final static String foo = "3";
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -8,9 +8,10 @@ import java.util.Map;
|
||||
import net.sourceforge.pmd.AbstractRule;
|
||||
import net.sourceforge.pmd.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.ast.ASTFieldDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTName;
|
||||
import net.sourceforge.pmd.ast.ASTReferenceType;
|
||||
import net.sourceforge.pmd.ast.ASTPrimitiveType;
|
||||
import net.sourceforge.pmd.ast.ASTType;
|
||||
import net.sourceforge.pmd.ast.ASTVariableDeclarator;
|
||||
@ -71,8 +72,13 @@ public class VariableNamingConventions extends AbstractRule {
|
||||
private Object checkNames(ASTFieldDeclaration node, Object data) {
|
||||
ASTType childNodeType = (ASTType) node.jjtGetChild(0);
|
||||
String varType = "";
|
||||
if (childNodeType.jjtGetChild(0) instanceof ASTName) {
|
||||
varType = ((ASTName) childNodeType.jjtGetChild(0)).getImage();
|
||||
if (childNodeType.jjtGetChild(0) instanceof ASTReferenceType ) {
|
||||
ASTReferenceType refType = ((ASTReferenceType) childNodeType.jjtGetChild(0));
|
||||
if ( refType.jjtGetChild(0) instanceof ASTClassOrInterfaceType ) {
|
||||
varType = ((ASTClassOrInterfaceType)refType.jjtGetChild(0)).getImage();
|
||||
} else {
|
||||
varType = "";
|
||||
}
|
||||
} else if (childNodeType.jjtGetChild(0) instanceof ASTPrimitiveType) {
|
||||
varType = ((ASTPrimitiveType) childNodeType.jjtGetChild(0)).getImage();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user