

def _CheckUnusedLocalVariables(self, token, state):
    'Checks for unused local variables in function blocks.\n\n    Args:\n      token: The token to check.\n      state: The state tracker.\n    '
    in_function = (state.FunctionDepth() > 0)
    if ((token.type == Type.SIMPLE_LVALUE) or (token.type == Type.IDENTIFIER)):
        if in_function:
            identifier = token.string
            previous_code_token = tokenutil.CustomSearch(token, (lambda t: (t.type not in Type.NON_CODE_TYPES)), reverse=True)
            if (previous_code_token and previous_code_token.IsKeyword('var')):
                self._unused_local_variables_by_scope[(- 1)][identifier] = token
            elif (token.type == Type.IDENTIFIER):
                self._MarkLocalVariableUsed(token.string)
            elif ((token.type == Type.SIMPLE_LVALUE) and ('.' in identifier)):
                self._MarkLocalVariableUsed(token.string)
    elif (token.type == Type.START_BLOCK):
        if (in_function and state.IsFunctionOpen()):
            self._unused_local_variables_by_scope.append({
                
            })
    elif (token.type == Type.END_BLOCK):
        if state.IsFunctionClose():
            unused_local_variables = self._unused_local_variables_by_scope.pop()
            for unused_token in unused_local_variables.values():
                self._HandleError(errors.UNUSED_LOCAL_VARIABLE, ('Unused local variable: %s.' % unused_token.string), unused_token)
    elif (token.type == Type.DOC_FLAG):
        flag = token.attached_object
        js_type = (flag and flag.jstype)
        if (flag and (flag.flag_type in state.GetDocFlag().HAS_TYPE) and js_type):
            self._MarkAliasUsed(js_type)

dataset/ETHPy150Open google/closure-linter/closure_linter/javascriptlintrules.py JavaScriptLintRules._CheckUnusedLocalVariables/original