Finds unmodified references which are inside of a loop condition.
Then reports the references which are outside of groups.

@param {eslint-scope.Variable} variable - A variable to report.
@returns {void}
485827
function checkReferences(variable) {

            // Gets references that exist in loop conditions.
            const conditions = variable
                .references
                .map(toLoopCondition)
                .filter(Boolean);

            if (conditions.length === 0) {
                return;
            }

            // Registers the conditions to belonging groups.
            registerConditionsToGroup(conditions);

            // Check the conditions are modified.
            const modifiers = variable.references.filter(isWriteReference);

            if (modifiers.length > 0) {
                updateModifiedFlag(conditions, modifiers);
            }

            /*
             * Reports the conditions which are not belonging to groups.
             * Others will be reported after all variables are done.
             */
            conditions
                .filter(isUnmodifiedAndNotBelongToGroup)
                .forEach(report);
        }
228429
function isSelfReference(ref, nodes) {
            let scope = ref.from;

            while (scope) {
                if (nodes.indexOf(scope.block) >= 0) {
                    return true;
                }

                scope = scope.upper;
            }

            return false;
        }
743734
function findVariableReferences (ast, identifier, skip) {
  var references = [];
  traverse.traverse(ast, {
    enter: function (node, parent) {
      if (node === skip) {
        this.skip();
      }
      else if (
          node.type === 'Identifier' &&
          node.name === identifier.name &&
          (parent.type !== 'MemberExpression' || parent.left !== node)
      ) {
        references.push(node);
      }
    }
  });
  return references;
}
877602
function isForInRef(ref) {
            let target = ref.identifier.parent;


            // "for (var ...) { return; }"
            if (target.type === "VariableDeclarator") {
                target = target.parent.parent;
            }

            if (target.type !== "ForInStatement") {
                return false;
            }

            // "for (...) { return; }"
            if (target.body.type === "BlockStatement") {
                target = target.body.body[0];

            // "for (...) return;"
            } else {
                target = target.body;
            }

            // For empty loop body
            if (!target) {
                return false;
            }

            return target.type === "ReturnStatement";
        }
559487
function isAfterLastUsedArg(variable) {
            const def = variable.defs[0];
            const params = context.getDeclaredVariables(def.node);
            const posteriorParams = params.slice(params.indexOf(variable) + 1);

            // If any used parameters occur after this parameter, do not report.
            return !posteriorParams.some(v => v.references.length > 0 || v.eslintUsed);
        }
97039
function isShadowed(scope, node) {
    const reference = findReference(scope, node);

    return reference && reference.resolved && reference.resolved.defs.length > 0;
}
390526
function report(condition) {
            const node = condition.reference.identifier;

            context.report({
                node,
                message: "'{{name}}' is not modified in this loop.",
                data: node
            });
        }
1291811
function references(node, scope, state) {
  var declared = state.letRefs[node.name];
  if (!declared) return false;

  // declared node is different in this scope
  return scope.getBindingIdentifier(node.name) === declared;
}
885055
function Reference(ident, scope, flag,writeExpr, maybeImplicitGlobal, partial, init) {
      /**
       * Identifier syntax node.
       * @member {esprima#Identifier} Reference#identifier
       */
      this.identifier = ident;
      /**
       * Reference to the enclosing Scope.
       * @member {Scope} Reference#from
       */
      this.from = scope;
      /**
       * Whether the reference comes from a dynamic scope (such as 'eval',
       * 'with', etc.), and may be trapped by dynamic scopes.
       * @member {boolean} Reference#tainted
       */
      this.tainted = false;
      /**
       * The variable this reference is resolved with.
       * @member {Variable} Reference#resolved
       */
      this.resolved = null;
      /**
       * The read-write mode of the reference. (Value is one of {@link
       * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
       * @member {number} Reference#flag
       * @private
       */
      this.flag = flag;
      if (this.isWrite()) {
          /**
           * If reference is writeable, this is the tree being written to it.
           * @member {esprima#Node} Reference#writeExpr
           */
          this.writeExpr = writeExpr;
          /**
           * Whether the Reference might refer to a partial value of writeExpr.
           * @member {boolean} Reference#partial
           */
          this.partial = partial;
          /**
           * Whether the Reference is to write of initialization.
           * @member {boolean} Reference#init
           */
          this.init = init;
      }
      this.__maybeImplicitGlobal = maybeImplicitGlobal;
  }
320748
public VariableRef[] getOutOfScopeVariableRefs() {
        Scope parent;
        if ((parent = getParent()) == null) {
            return new VariableRef[0];
        }

        Collection<VariableRef> allRefs = new ArrayList<VariableRef>();
        fillVariableRefs(allRefs, this);

        Collection<VariableRef> refs =
            new ArrayList<VariableRef>(allRefs.size());

        Iterator<VariableRef> it = allRefs.iterator();
        while (it.hasNext()) {
            VariableRef ref = it.next();
            Variable var = ref.getVariable();
            if (var != null &&
                parent.getDeclaredVariable(var.getName()) == var) {
                refs.add(ref);
            }
        }

        VariableRef[] refsArray = new VariableRef[refs.size()];
        return refs.toArray(refsArray);
    }
1276047
private boolean eachVariableOccursOnlyOnce() {
        int lit;
        for (int i = 0; i < this.addedlits.size(); i++) {
            lit = this.addedlits.get(i);
            assert marked(lit) == 0;
            assert marked(-lit) == 0;
        }
        boolean res = true;
        for (int i = 0; i < this.addedlits.size(); i++) {
            lit = this.addedlits.get(i);
            if (marked(lit) != 0 || marked(-lit) != 0) { res = false; } else { mark(lit); }
        }
        unmark();
        return res;
    }
31924
function checkReference(references) {
            astUtils.getModifyingReferences(references).forEach(reference => {
                context.report({ node: reference.identifier, message: "'{{name}}' is a function.", data: { name: reference.identifier.name } });
            });
        }
791588
@Override
    boolean hasReference(RangeVariable range) {

        if (range == rangeVariable) {
            return true;
        }

        for (int i = 0; i < nodes.length; i++) {
            if (nodes[i] != null) {
                if (nodes[i].hasReference(range)) {
                    return true;
                }
            }
        }

        return false;
    }
1288264
private boolean isGlobalVarReference(String name, Scope s) {
    Var v = s.getVar(name);
    if (v == null && externsScope != null) {
      v = externsScope.getVar(name);
    }
    return v != null && !v.isLocal();
  }
487032
public final void variable_reference() throws RecognitionException {
		CommonTree varref=null;
		CommonTree lit=null;

		try {
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:150:5: ( ^(varref= VT_VAR_REF lit= LITERAL ) )
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:150:7: ^(varref= VT_VAR_REF lit= LITERAL )
			{
			varref=(CommonTree)match(input,VT_VAR_REF,FOLLOW_VT_VAR_REF_in_variable_reference471); 
			match(input, Token.DOWN, null); 
			lit=(CommonTree)match(input,LITERAL,FOLLOW_LITERAL_in_variable_reference475); 
			match(input, Token.UP, null); 


			        entry_stack.peek().valuebuffer.append("{" + (lit!=null?lit.getText():null) + "}" );
			         entry_stack.peek().sentenceValueBuffer.append("{"+(lit!=null?lit.getText():null)+"}");
			    
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
	}
420112
function checkVariable(variable) {
            if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
                variable.references.forEach(checkReference);
            }
        }
595031
private VariableLiveness isVariableReadBeforeKill(
      Node n, String variable) {
    if (ControlFlowGraph.isEnteringNewCfgNode(n)) { // Not a FUNCTION
      return VariableLiveness.MAYBE_LIVE;
    }

    if (n.isName() && variable.equals(n.getString())) {
      if (NodeUtil.isNameDeclOrSimpleAssignLhs(n, n.getParent())) {
        checkState(n.getParent().isAssign(), n.getParent());
        // The expression to which the assignment is made is evaluated before
        // the RHS is evaluated (normal left to right evaluation) but the KILL
        // occurs after the RHS is evaluated.
        Node rhs = n.getNext();
        VariableLiveness state = isVariableReadBeforeKill(rhs, variable);
        if (state == VariableLiveness.READ) {
          return state;
        }
        return VariableLiveness.KILL;
      } else {
        return VariableLiveness.READ;
      }
    }

    switch (n.getToken()) {
      // Conditionals
      case OR:
      case AND:
        VariableLiveness v1 = isVariableReadBeforeKill(
          n.getFirstChild(), variable);
        VariableLiveness v2 = isVariableReadBeforeKill(
          n.getLastChild(), variable);
        // With a AND/OR the first branch always runs, but the second is
        // may not.
        if (v1 != VariableLiveness.MAYBE_LIVE) {
          return v1;
        } else if (v2 == VariableLiveness.READ) {
          return VariableLiveness.READ;
        } else {
          return VariableLiveness.MAYBE_LIVE;
        }
      case HOOK:
        VariableLiveness first = isVariableReadBeforeKill(
            n.getFirstChild(), variable);
        if (first != VariableLiveness.MAYBE_LIVE) {
          return first;
        }
        return checkHookBranchReadBeforeKill(
            n.getSecondChild(), n.getLastChild(), variable);

      default:
        // Expressions are evaluated left-right, depth first.
        for (Node child = n.getFirstChild();
            child != null; child = child.getNext()) {
          VariableLiveness state = isVariableReadBeforeKill(child, variable);
          if (state != VariableLiveness.MAYBE_LIVE) {
            return state;
          }
        }
    }

    return VariableLiveness.MAYBE_LIVE;
  }