We can just call iterater(); no need to call isEmpty() first

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4759 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-10-29 20:05:06 +00:00
parent 15d1c24887
commit e1f2b92783

View File

@ -28,15 +28,13 @@ public class AvoidFieldNameMatchingMethodName extends AbstractRule {
ASTClassOrInterfaceDeclaration cl = (ASTClassOrInterfaceDeclaration) node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
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);
}
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);
}
}
}