Source:
public Object visit(ASTForStatement node, Object data) { final ASTForInit init = node.getFirstChildOfType(ASTForInit.class); final ASTForUpdate update = node.getFirstChildOfType(ASTForUpdate.class); final ASTExpression guardCondition = node.getFirstChildOfType(ASTExpression.class); if (init == null && update == null || guardCondition == null) { return super.visit(node, data); } Entry<VariableNameDeclaration, List<NameOccurrence>> indexDecl = getIndexVarDeclaration(init, update); if (indexDecl == null) { return super.visit(node, data); } List<NameOccurrence> occurrences = indexDecl.getValue(); VariableNameDeclaration index = indexDecl.getKey(); if ("Iterator".equals(index.getTypeImage()) && isReplaceableIteratorLoop(indexDecl, guardCondition, update)) { addViolation(data, node); } if (occurrences == null || !"int".equals(index.getTypeImage()) || !indexStartsAtZero(index)) { return super.visit(node, data); } String itName = index.getName(); String iterableName = getIterableNameOrNullToAbort(guardCondition, itName); if (!isForUpdateSimpleEnough(update, itName) || iterableName == null) { return super.visit(node, data); } Entry<VariableNameDeclaration, List<NameOccurrence>> iterableInfo = findDeclaration(iterableName, node.getScope()); VariableNameDeclaration iterableDeclaration = iterableInfo == null ? null : iterableInfo.getKey(); if (iterableDeclaration == null) { return super.visit(node, data); } if (iterableDeclaration.isArray() && isReplaceableArrayLoop(node, occurrences, iterableDeclaration)) { addViolation(data, node); } else if (iterableDeclaration.getTypeImage() != null && iterableDeclaration.getTypeImage() .matches("List|ArrayList|LinkedList") && isReplaceableListLoop(node, occurrences, iterableDeclaration)) { addViolation(data, node); } return super.visit(node, data); }

Target:
public Object visit(ASTForStatement node, Object data) { final ASTForInit init = node.getFirstChildOfType(ASTForInit.class); final ASTForUpdate update = node.getFirstChildOfType(ASTForUpdate.class); final ASTExpression guardCondition = node.getFirstChildOfType(ASTExpression.class); if (init == null && update == null || guardCondition == null) { return super.visit(node, data); } Entry<VariableNameDeclaration, List<NameOccurrence>> indexDecl = getIndexVarDeclaration(init, update); if (indexDecl == null) { return super.visit(node, data); } List<NameOccurrence> occurrences = indexDecl.getValue(); VariableNameDeclaration index = indexDecl.getKey(); if (TypeHelper.isA(index, Iterator.class)) { Entry<VariableNameDeclaration, List<NameOccurrence>> iterableInfo = getIterableDeclOfIteratorLoop(index, node.getScope()); if (iterableInfo != null && isReplaceableIteratorLoop(indexDecl, guardCondition, iterableInfo, node)) { addViolation(data, node); } return data; } if (occurrences == null || !"int".equals(index.getTypeImage()) || !indexStartsAtZero(index)) { return super.visit(node, data); } String itName = index.getName(); String iterableName = getIterableNameOrNullToAbort(guardCondition, itName); if (!isForUpdateSimpleEnough(update, itName) || iterableName == null) { return super.visit(node, data); } Entry<VariableNameDeclaration, List<NameOccurrence>> iterableInfo = findDeclaration(iterableName, node.getScope()); VariableNameDeclaration iterableDeclaration = iterableInfo == null ? null : iterableInfo.getKey(); if (iterableDeclaration == null) { return super.visit(node, data); } if (iterableDeclaration.isArray() && isReplaceableArrayLoop(node, occurrences, iterableDeclaration)) { addViolation(data, node); } else if (iterableDeclaration.getTypeImage() != null && iterableDeclaration.getTypeImage() .matches("List|ArrayList|LinkedList") && isReplaceableListLoop(node, occurrences, iterableDeclaration)) { addViolation(data, node); } return super.visit(node, data); }