Fixed bug 1448123 - AvoidFieldNameMatchingMethodName no longer errors out on enumerations.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4294 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -19,7 +19,7 @@ Fixed bug 1435751 - Added encoding type of UTF-8 to the CPD XML file.
|
||||
Fixed bug 1441539 - ConsecutiveLiteralAppends no longer flags appends() involving method calls.
|
||||
Fixed bug 1339470 - PMD no longer fails to parse certain non-static initializers.
|
||||
Fixed bug 1425772 - PMD no longer fails with errors in ASTFieldDeclaration when parsing some JDK 1.5 code.
|
||||
Fixed bug 1448123 - AvoidFieldNameMatchingTypeName no longer errors out on enumerations.
|
||||
Fixed bug 1448123 - AvoidFieldNameMatchingTypeName and AvoidFieldNameMatchingMethodName no longer error out on enumerations.
|
||||
Fixed bug 1444654 - migrating_to_14 and migrating_to_15 no longer refer to rule tests.
|
||||
Fixed bug 1445231 - TestClassWithoutTestCases: no longer flags abstract classes.
|
||||
Fixed bug 1445765 - PMD no longer uses huge amounts of memory. However, you need to use RuleViolation.getBeginLine(); RuleViolation.getNode() is no more.
|
||||
|
@ -26,15 +26,17 @@ public class AvoidFieldNameMatchingMethodName extends AbstractRule {
|
||||
if (varName != null) {
|
||||
varName = varName.toLowerCase();
|
||||
ASTClassOrInterfaceDeclaration cl = (ASTClassOrInterfaceDeclaration) node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
|
||||
List methods = cl.findChildrenOfType(ASTMethodDeclaration.class);
|
||||
if (!methods.isEmpty()) {
|
||||
for (Iterator it = methods.iterator(); it.hasNext();) {
|
||||
ASTMethodDeclaration m = (ASTMethodDeclaration) it.next();
|
||||
//Make sure we are comparing fields and methods inside same type
|
||||
if (fieldDeclaringType.equals(getDeclaringType(m))) {
|
||||
String n = m.getMethodName();
|
||||
if (varName.equals(n.toLowerCase())) {
|
||||
addViolation(data, node);
|
||||
if (cl != null) {
|
||||
List methods = cl.findChildrenOfType(ASTMethodDeclaration.class);
|
||||
if (!methods.isEmpty()) {
|
||||
for (Iterator it = methods.iterator(); it.hasNext();) {
|
||||
ASTMethodDeclaration m = (ASTMethodDeclaration) it.next();
|
||||
//Make sure we are comparing fields and methods inside same type
|
||||
if (fieldDeclaringType.equals(getDeclaringType(m))) {
|
||||
String n = m.getMethodName();
|
||||
if (varName.equals(n.toLowerCase())) {
|
||||
addViolation(data, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user