Perform static analysis on the given file.

    :param filename: path of file to check.
    :type filename: str
    :param ignore: codes to ignore, e.g. ``('E111', 'E123')``
    :type ignore: `list`
    :param select: codes to explicitly select.
    :type select: `list`
    :param pyflakes: run the pyflakes checks too (default ``True``)
    :type pyflakes: bool
    :return: errors
    :rtype: `list`

    .. seealso:: :py:class:`pycodestyle.Checker`

def check_pep8(filename, **kwargs):
    """Perform static analysis on the given file.

    :param filename: path of file to check.
    :type filename: str
    :param ignore: codes to ignore, e.g. ``('E111', 'E123')``
    :type ignore: `list`
    :param select: codes to explicitly select.
    :type select: `list`
    :param pyflakes: run the pyflakes checks too (default ``True``)
    :type pyflakes: bool
    :return: errors
    :rtype: `list`

    .. seealso:: :py:class:`pycodestyle.Checker`
    """
    options = {
        "ignore": kwargs.get("ignore"),
        "select": kwargs.get("select"),
    }

    if not _registered_pyflakes_check and kwargs.get("pyflakes", True):
        _register_pyflakes_check()

    checker = pep8.Checker(filename, reporter=_Report, **options)
    checker.check_all()

    errors = []
    for error in sorted(checker.report.errors, key=lambda x: x[0]):
        errors.append("{0}:{1}: {3}".format(*error))
    return errors