Check for unused function parameters.

This function is launched at the end of a function
485475
private function _checkUnusedFunctionParameters() {
		if ($this->_isActive('checkUnusedFunctionParameters')) {

			// If the docblock is inherited, this means that the function implements a parent function
			// We may have some unused parameters in this case, we don't generate a warnings
			if (!$this->statementStack->getParentStackItem()->docblocInheritDoc) {

				foreach ($this->_functionParameters as $variableName => $value) {
					if ($value !== "used") {
						$msg = $this->_getMessage('UNUSED_FUNCTION_PARAMETER', $this->_currentFunctionName, $variableName);
						$this->_writeError('checkUnusedFunctionParameters', $msg);
					}
				}
			}
		}
	}
1347136
def main(arguments=None):   # suppress(unused-function)
    """"""
    result = _parse_arguments(arguments)
    linter_funcs = _ordered(linter_functions_from_filters,
                            result.whitelist,
                            result.blacklist)
    global_options = vars(result)
    tool_options = tool_options_from_global(global_options, len(result.files))
    any_would_run = _any_would_run(_run_lint_on_file_exceptions,
                                   result.files,
                                   result.stamp_file_path,
                                   result.log_technical_terms_to,
                                   linter_funcs,
                                   tool_options,
                                   result.fix_what_you_can)

    if any_would_run:
        for linter_function in linter_funcs.values():
            if linter_function.before_all:
                linter_function.before_all(global_options, tool_options)

        use_multiprocessing = _should_use_multiprocessing(len(result.files))
    else:
        use_multiprocessing = False

    if use_multiprocessing:
        mapper = parmap.map
    else:
        # suppress(E731)
        mapper = lambda f, i, *a: [f(*((x, ) + a)) for x in i]

    errors = list(itertools.chain(*mapper(_run_lint_on_file_stamped,
                                          result.files,
                                          result.stamp_file_path,
                                          result.log_technical_terms_to,
                                          linter_funcs,
                                          tool_options,
                                          result.fix_what_you_can)))

    for error in sorted(errors):
        _report_lint_error(error.failure, os.path.relpath(error.absolute_path))

    if any_would_run:
        for linter_funcs in linter_funcs.values():
            if linter_funcs.after_all:
                linter_funcs.after_all(global_options, tool_options)

    return len(errors)
1064202
def __is_function_action(self, action_function):
        
        # test if function returns a couple of values
        is_function_action = True

        if not hasattr(action_function, '__call__'):
            return False

        # OK, callable. Do we receive the right arguments?
        try:
            for end_string, context in action_function():
                if not isinstance(end_string, basestring):
                    self.log_error("Action function must return end of filename as a string as first argument")
                if not isinstance(context, dict):
                    self.log_error("Action function must return context as a dict as second argument")
                break
        except Exception:
            is_function_action = False

        return is_function_action
182553
def _reduce_method(cls, func):
        

        def wrapped_func(self, **kwargs):
            return self.reduce(func, **kwargs)
        return wrapped_func
260656
def on_functiondef(self, node):
        """"""
        # ('name', 'args', 'body', 'decorator_list')
        if node.decorator_list:
            raise Warning("decorated procedures not supported!")
        kwargs = []

        if not valid_symbol_name(node.name) or node.name in self.readonly_symbols:
            errmsg = "invalid function name (reserved word?) %s" % node.name
            self.raise_exception(node, exc=NameError, msg=errmsg)

        offset = len(node.args.args) - len(node.args.defaults)
        for idef, defnode in enumerate(node.args.defaults):
            defval = self.run(defnode)
            keyval = self.run(node.args.args[idef+offset])
            kwargs.append((keyval, defval))

        if version_info[0] == 3:
            args = [tnode.arg for tnode in node.args.args[:offset]]
        else:
            args = [tnode.id for tnode in node.args.args[:offset]]

        doc = None
        nb0 = node.body[0]
        if isinstance(nb0, ast.Expr) and isinstance(nb0.value, ast.Str):
            doc = nb0.value.s

        varkws = node.args.kwarg
        vararg = node.args.vararg
        if version_info[0] == 3:
            if isinstance(vararg, ast.arg):
                vararg = vararg.arg
            if isinstance(varkws, ast.arg):
                varkws = varkws.arg

        self.symtable[node.name] = Procedure(node.name, self, doc=doc,
                                             lineno=self.lineno,
                                             body=node.body,
                                             args=args, kwargs=kwargs,
                                             vararg=vararg, varkws=varkws)
        if node.name in self.no_deepcopy:
            self.no_deepcopy.remove(node.name)
924835
void trimWhitespaceFromFunctionEnd() {
		assert (callStack.getCurrentElement().type == PushPopType.Function);

		int functionStartPoint = callStack.getCurrentElement().functionStartInOuputStream;

		// If the start point has become -1, it means that some non-whitespace
		// text has been pushed, so it's safe to go as far back as we're able.
		if (functionStartPoint == -1) {
			functionStartPoint = 0;
		}

		// Trim whitespace from END of function call
		for (int i = outputStream.size() - 1; i >= functionStartPoint; i--) {
			RTObject obj = outputStream.get(i);

			if (!(obj instanceof StringValue))
				continue;
			StringValue txt = (StringValue) obj;

			if (obj instanceof ControlCommand)
				break;

			if (txt.isNewline() || txt.isInlineWhitespace()) {
				outputStream.remove(i);
				outputStreamDirty();
			} else {
				break;
			}
		}
	}
150177
private function _checkFunctionLength() {
		// Check the length of the function
		if ($this->_isActive('functionLength')) {

			$functionLength = $this->lineNumber - $this->_functionStartLine;
			$maxLength = $this->_config->getTestProperty('functionLength', 'maxLength');

			if ($functionLength > $maxLength) {
				$msg = $this->_getMessage('FUNCTION_LENGTH_THROW', $this->_currentFunctionName, $functionLength, $maxLength);
				$this->_writeError('docBlocks', $msg);
			}
		}
	}
1220764
function findUnusedVariableDeclarators (ast) {
  var unused = [];
  traverse.traverse(ast, {
    enter: function (node, parent) {
      var scope, refs;
      if (node.type === 'VariableDeclarator' && (scope = findScope(ast, node))) {
        refs = fast.filter(findVariableReferences(scope, node.id), function (item) {
          return item !== node.id;
        });

        if (!refs.length) {
          unused.push(node);
        }
      }
    }
  });
  return unused;
}
241199
function end() {
		var err
		var args = Array.prototype.slice.call(arguments)
		var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
		if (self.writable && args.length) write.apply(this, args.concat(afterWrite))
		else afterWrite()

		function afterWrite(e) {
			if (e) err = e
			destroy(afterDestroy)
		}

		function afterDestroy(e) {
			if (e && !err) err = e
			if (cb) {
				var cbArgs = []
				if (err) cbArgs.push(err)
				cb.apply(this, cbArgs)
			}
		}
	}
832365
private function _checkUnusedCode($endToken) {
		if ($this->_isActive('checkUnusedCode')) {

			// The check is done only when we are at the root level of a function
			if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_FUNCTION) {

				// Find the end of the return statement
				$pos = $this->tokenizer->findNextStringPosition(';');

				// Find the next valid token after the return statement
				$nextValidToken = $this->tokenizer->peekNextValidToken($pos + 1);

				// Find the end of the function or bloc of code
				$posClose = $this->tokenizer->findNextStringPosition('}');

				// If the end of bloc if not right after the return statement, we have dead code
				if ($nextValidToken !== null && $posClose > $nextValidToken->position) {
					$msg = $this->_getMessage('UNUSED_CODE', $this->statementStack->getCurrentStackItem()->name, $endToken);
					$this->_writeError('checkUnusedCode', $msg);
				}
			}
		}
	}
528434
def _check_count(self, result, func, args):
        #pylint: disable=unused-argument
        
        if result == 0:
            raise ctypes.WinError(ctypes.get_last_error())
        return args
877765
function unused(src) {
    var ast = esprima.parse(src, {
        loc: true
    });

    // map of identifiers -> location
    // when an identifier is seen, it is removed from the map
    var unused_vars = [];

    function exec(node, context) {
        if (!node) {
            return;
        }

        handlers[node.type](node, context);
    };

    function maybe_set_id(id, context, is_param) {
        if (!id) {
            return;
        }

        if (id.type !== 'Identifier') {
            exec(id, context);
            return;
        }

        context.set(id.name, {
            name: id.name,
            loc: id.loc.start,
            param: is_param || false
        });
    }

    function maybe_set_param(id, context) {
        maybe_set_id(id, context, true);
    }

    var handlers = {
        VariableDeclaration: function(node, context) {
            node.declarations.forEach(function(node) {
                exec(node, context)
            });
        },
        VariableDeclarator: function(node, context) {
            maybe_set_id(node.id, context);
            exec(node.init, context);
        },
        FunctionExpression: function(node, context) {
            // function express ids are ignored
            // assume user specified it for backtrace reasons

            var ctx = new Context(context);

            // parameters are within the context of the function
            node.params.forEach(function(node) {
                maybe_set_param(node, ctx);
            });

            // exec function body with new context
            exec(node.body, ctx);

            Array.prototype.push.apply(unused_vars, ctx.unused());
        },
        FunctionDeclaration: function(node, context) {
            maybe_set_id(node.id, context);

            var ctx = new Context(context);

            // parameters are within the context of the function
            node.params.forEach(function(node) {
                maybe_set_param(node, ctx);
            });

            // exec function body with new context
            exec(node.body, ctx);

            Array.prototype.push.apply(unused_vars, ctx.unused());
        },
        BlockStatement: function(node, context) {
            node.body.forEach(function(node) {
                exec(node, context);
            });
        },
        CallExpression: function(node, context) {
            exec(node.callee, context);

            node.arguments.forEach(function(node) {
                exec(node, context);
            });
        },
        MemberExpression: function(node, context) {
            exec(node.object, context);
            exec(node.property, context);
        },
        ExpressionStatement: function(node, context) {
            exec(node.expression, context);
        },
        ObjectExpression: function(node, context) {
            node.properties.forEach(function(node) {
                exec(node, context);
            });
        },
        AssignmentExpression: function(node, context) {
            exec(node.left, context);
            exec(node.right, context);
        },
        LogicalExpression: function(node, context) {
            exec(node.left, context);
            exec(node.right, context);
        },
        BinaryExpression: function(node, context) {
            exec(node.left, context);
            exec(node.right, context);
        },
        TryStatement: function(node, context) {
            node.block.body.forEach(function(node) {
                exec(node, context);
            });

            node.handlers.forEach(function(node) {
                exec(node, context);
            });
        },
        CatchClause: function(node, context) {
            exec(node.param, context);
            exec(node.body, context);
        },
        ConditionalExpression: function(node, context) {
            exec(node.test, context);
            exec(node.consequent, context);
            exec(node.alternate, context);
        },
        ArrayExpression: function(node, context) {
            node.elements.forEach(function(node) {
                exec(node, context);
            });
        },
        UpdateExpression: function(node, context) {
            exec(node.argument, context);
        },
        UnaryExpression: function(node, context) {
            exec(node.argument, context);
        },
        ThrowStatement: function(node, context) {
            exec(node.argument, context);
        },
        IfStatement: function(node, context) {
            exec(node.test, context);
            exec(node.consequent, context);
            exec(node.alternate, context);
        },
        ReturnStatement: function(node, context) {
            exec(node.argument, context);
        },
        SwitchStatement: function(node, context) {
            exec(node.discriminant, context);
            node.cases.forEach(function(node) {
                exec(node, context);
            });
        },
        SwitchCase: function(node, context) {
            exec(node.test, context);
            node.consequent.forEach(function(node) {
                exec(node, context);
            });
        },
        NewExpression: function(node, context) {
            exec(node.callee, context);
            node.arguments.forEach(function(node) {
                exec(node, context);
            });
        },
        Property: function(node, context) {
            exec(node.key, context);
            exec(node.value, context);
        },
        ForInStatement: function(node, context) {
            exec(node.left, context);
            exec(node.right, context);
            exec(node.body, context);
        },
        WhileStatement: function(node, context) {
            exec(node.test, context);
            exec(node.body, context);
        },
        SequenceExpression: function(node, context) {
            node.expressions.forEach(function(node) {
                exec(node, context);
            });
        },
        ForStatement: function(node, context) {
            exec(node.init, context);
            exec(node.test, context);
            exec(node.update, context);
            exec(node.body, context);
        },
        DoWhileStatement: function(node, context) {
            exec(node.body, context);
            exec(node.test, context);
        },
        ContinueStatement: function() {
        },
        BreakStatement: function() {
        },
        ThisExpression: function() {
        },
        EmptyStatement: function() {
        },
        Literal: function() {
        },
        Identifier: function(node, context) {
            context.remove(node.name);
        },
    };

    // TODO handle the case where use of a variable comes before declaring it
    // while this seems retarded, javascript does allow it

    var body = ast.body;

    var ctx = new Context();

    body.forEach(function(node) {
        exec(node, ctx);
    });

    Array.prototype.push.apply(unused_vars, ctx.unused());

    return unused_vars;
}
473722
def get_used_in_func(node):
    '''
    '''
    if isinstance(node, ast.FunctionDef):
        return {node.name: get_accessed(node.body)}
    names = {}
    for node in ast.iter_child_nodes(node):
        names.update(get_used_in_func(node))
    return names
68824
def _check_unpack_options(extensions, function, extra_args):
    """"""
    # first make sure no other unpacker is registered for this extension
    existing_extensions = {}
    for name, info in _UNPACK_FORMATS.items():
        for ext in info[0]:
            existing_extensions[ext] = name

    for extension in extensions:
        if extension in existing_extensions:
            msg = '%s is already registered for "%s"'
            raise RegistryError(msg % (extension,
                                       existing_extensions[extension]))

    if not isinstance(function, collections.Callable):
        raise TypeError('The registered function must be a callable')
1108724
function removeUnusedVariableDeclarators (ast) {
  var unused = findUnusedVariableDeclarators(ast);
  traverse.traverse(ast, {
    enter: function (node, parent) {
      if (node.type !== 'VariableDeclaration') {
        return;
      }
      node.declarations = fast.filter(node.declarations, function (item) {
        return !~fast.indexOf(unused, item);
      });
    }
  });
  return ast;
}
149468
def function_end(self):
        """"""
        self.newline_label(self.shared.function_name + "_exit", True, True)
        self.move("%14", "%15")
        self.pop("%14")
        self.newline_text("RET", True)
965565
def exclude_functions(self, *funcs):
        
        for f in funcs:
            f.exclude = True
        run_time_s = sum(0 if s.exclude else s.own_time_s for s in self.stats)
        cProfileFuncStat.run_time_s = run_time_s