Run lint checks using flake8.
551510
def lint(args):
    """"""
    application = get_current_application()
    if not args:
        args = [application.name, 'tests']
    args = ['flake8'] + list(args)
    run.main(args, standalone_mode=False)
1356569
def _report_lint_error(error, file_path):
    """"""
    line = error[1].line
    code = error[0]
    description = error[1].description
    sys.stdout.write("{0}:{1} [{2}] {3}\n".format(file_path,
                                                  line,
                                                  code,
                                                  description))
717462
function lint (options) {
  if (!options.language) {
    throw new Error('options.language missing')
  }

  if (!Array.isArray(options.arguments)) {
    throw new TypeError('options.arguments has to be an array')
  }

  process.env.NODE_ENV = 'development'

  if (options.language === 'css') {
    process.env.PANGOLIN_ENV = 'lint:css'

    lintCSS(options.arguments)
      ? process.exit(0)
      : process.exit(1)
  }

  if (options.language === 'js') {
    process.env.PANGOLIN_ENV = 'lint:js'

    lintJS(options.arguments)
      ? process.exit(0)
      : process.exit(1)
  }
}
1237586
def run_lint_command():
    
    lint, app_dir, lint_result, ignore_layouts = parse_args()
    if not lint_result:
        if not distutils.spawn.find_executable(lint):
            raise Exception(
                '`%s` executable could not be found and path to lint result not specified. See --help' % lint)
        lint_result = os.path.join(app_dir, 'lint-result.xml')
        call_result = subprocess.call([lint, app_dir, '--xml', lint_result])
        if call_result > 0:
            print('Running the command failed with result %s. Try running it from the console.'
                  ' Arguments for subprocess.call: %s' % (call_result, [lint, app_dir, '--xml', lint_result]))
    else:
        if not os.path.isabs(lint_result):
            lint_result = os.path.join(app_dir, lint_result)
    lint_result = os.path.abspath(lint_result)
    return lint_result, app_dir, ignore_layouts
1291339
def run(self, args):
        
        # set output stream.
        if self.outputStream:
            self.linter.reporter.set_output(self.outputStream)
        try:
            args = self.linter.load_command_line_configuration(args)
        except SystemExit as exc:
            if exc.code == 2:  # bad options
                exc.code = 32
            raise
        if not args:
            self.displayHelp()
        # Check for 'strict-epydoc' option.
        if self.allowOptions and not self.linter.option_value("strict-epydoc"):
            for msg in ["W9203", "W9205"]:
                self.linter.disable(msg)

        # insert current working directory to the python path to have a correct
        # behaviour.
        sys.path.insert(0, os.getcwd())
        # set exceptions for name checking.
        self.setNameExceptions(args)

        # check for diff option.
        self.diffOption = self.linter.option_value("diff")
        if self.diffOption:
            self.prepareDiff()

        # check codes.
        self.linter.check(args)

        # show diff of warnings if diff option on.
        if self.diffOption:
            diffCount = self.showDiffResults()
            exitCode = 1 if diffCount else 0
            sys.exit(exitCode)

        sys.exit(self.linter.msg_status)
1290510
def run(**kwargs):
    """"""
    paths = kwargs.pop('paths', ())
    action = kwargs.pop('action')
    plugin = kwargs.pop('plugin')
    junit_xml = kwargs.pop('junit_xml')
    use_tracked_files = kwargs.pop('use_tracked_files')
    quiet = kwargs.pop('quiet')

    colorama.init(strip=kwargs.pop('no_color'))

    git_dir = current_git_dir()

    if git_dir is None:
        output(NOT_GIT_REPO_MSG)
        exit(1)

    repo_root = os.path.dirname(git_dir)

    files = []
    if paths:
        # We want to look at files in their current state if paths are passed through
        kwargs['include_unstaged_changes'] = True

        # If paths were provided get all the files for each path
        for path in paths:
            for f in list_files(path):
                f = os.path.relpath(f, repo_root)
                if not f.startswith('..'):  # Don't include files outside the repo root.
                    files.append(f)
    elif use_tracked_files:
        # If the use tracked files flag was passed, get a list of all the tracked files
        out, err, code = git.ls_files()
        files = out.splitlines()

        if kwargs.get('include_untracked'):
            out, err, code = git.ls_files(o=True, exclude_standard=True)
            files += out.splitlines()

    if files or paths:
        kwargs['files'] = files

    config = get_config(repo_root)
    runner = Runner(config.cwd, **kwargs)
    results = ResultCollection()

    if runner.unstaged_changes and not quiet:
        output(UNSTAGED_CHANGES_MSG, end='\n\n')

    processes = list(config.actions) + list(config.plugins)
    processes.sort(key=lambda x: x.name)  # Sort the list of processes for consistent results

    if plugin:
        try:
            processes = [config.plugins.get(plugin)]
        except config.plugins.DoesNotExist as e:
            output('{}\nAvailable plugins:'.format(e.message))

            for p in config.plugins:
                output(p.name)
            exit(1)

    if action:
        try:
            processes = [config.actions.get(action)]
        except config.actions.DoesNotExist as e:
            output('{}\nAvailable actions:'.format(e.message))

            for a in config.actions:
                output(a.name)
            exit(1)

    for process in processes:
        result, message = runner.run_process(process)
        results.append(result)

        if not quiet:
            output(message)

    if junit_xml:
        with open(junit_xml, 'w+') as f:
            f.write('{}'.format(results.dump_junit()))

    if not quiet:
        output(results.dump())
        output('#{{bright}}{}\nCompleted in: {}s'.format(''.ljust(79, '-'), round(results.execution_time, 2)))

    if results.has_error:
        exit(1)
    elif results.has_failure:
        exit(2)
1118275
def run(targets, config_dir='.', check_licenses=False):
    # type: (List[str], str, bool) -> None
    
    pylint_return_state = False
    flake8_return_state = False

    if check_licenses:
        run_license_checker(config_path=get_license_checker_config_path(config_dir))

    pylint_options = get_pylint_options(config_dir=config_dir)
    flake8_options = get_flake8_options(config_dir=config_dir)

    if targets:
        pylint_return_state = _run_command(command='pylint', targets=targets,
                                           options=pylint_options)
        flake8_return_state = _run_command(command='flake8', targets=targets,
                                           options=flake8_options)

    if not flake8_return_state and not pylint_return_state:
        sys.exit(0)
    else:
        sys.exit(1)
825925
def lint(filename):
    """"""
    config = ConfigParser.ConfigParser()
    try:
        config.read(filename)
        return 0
    except ConfigParser.Error as error:
        print('Error: %s' % error)
        return 1
    except:
        print('Unexpected Error')
        return 2
140324
def execute(self):
        
        self.print_info()
        linters = [
            l for l in [
                self._config.lint,
                self._config.verifier.lint,
                self._config.provisioner.lint,
            ] if l
        ]

        for l in linters:
            l.execute()
1360828
def lint_results
      bin = eslint_path
      raise 'eslint is not installed' unless bin
      return run_lint(bin, '.') unless filtering
      ((git.modified_files - git.deleted_files) + git.added_files)
        .select { |f| f.end_with? '.js' }
        .map { |f| f.gsub("#{Dir.pwd}/", '') }
        .map { |f| run_lint(bin, f).first }
    end
427016
def _run_spellcheck_linter(matched_filenames, cache_dir, show_lint_files):
    """"""
    from polysquarelinter import lint_spelling_only as lint
    from prospector.message import Message, Location

    for filename in matched_filenames:
        _debug_linter_status("spellcheck-linter", filename, show_lint_files)

    return_dict = dict()

    def _custom_reporter(error, file_path):
        line = error.line_offset + 1
        key = _Key(file_path, line, "file/spelling_error")
        loc = Location(file_path, None, None, line, 0)
        # suppress(protected-access)
        desc = lint._SPELLCHECK_MESSAGES[error.error_type].format(error.word)
        return_dict[key] = Message("spellcheck-linter",
                                   "file/spelling_error",
                                   loc,
                                   desc)

    # suppress(protected-access,unused-attribute)
    lint._report_spelling_error = _custom_reporter
    lint.main([
        "--spellcheck-cache=" + os.path.join(cache_dir, "spelling"),
        "--stamp-file-path=" + os.path.join(cache_dir,
                                            "jobstamps",
                                            "polysquarelinter"),
        "--technical-terms=" + os.path.join(cache_dir, "technical-terms"),
    ] + matched_filenames)

    return return_dict
621465
def _map_over_linters(self,
                          py_files,
                          non_test_files,
                          md_files,
                          stamp_directory,
                          mapper):
        """"""
        dispatch = [
            ("flake8", lambda: mapper(_run_flake8,
                                      py_files,
                                      stamp_directory,
                                      self.show_lint_files)),
            ("pyroma", lambda: [_stamped_deps(stamp_directory,
                                              _run_pyroma,
                                              "setup.py",
                                              self.show_lint_files)]),
            ("mdl", lambda: [_run_markdownlint(md_files,
                                               self.show_lint_files)]),
            ("polysquare-generic-file-linter", lambda: [
                _run_polysquare_style_linter(py_files,
                                             self.cache_directory,
                                             self.show_lint_files)
            ]),
            ("spellcheck-linter", lambda: [
                _run_spellcheck_linter(md_files,
                                       self.cache_directory,
                                       self.show_lint_files)
            ])
        ]

        # Prospector checks get handled on a case sub-linter by sub-linter
        # basis internally, so always run the mapper over prospector.
        #
        # vulture should be added again once issue 180 is fixed.
        prospector = (mapper(_run_prospector,
                             py_files,
                             stamp_directory,
                             self.disable_linters,
                             self.show_lint_files) +
                      [_stamped_deps(stamp_directory,
                                     _run_prospector_on,
                                     non_test_files,
                                     ["dodgy"],
                                     self.disable_linters,
                                     self.show_lint_files)])

        for ret in prospector:
            yield ret

        for linter, action in dispatch:
            if linter not in self.disable_linters:
                try:
                    for ret in action():
                        yield ret
                except Exception as error:
                    traceback.print_exc()
                    sys.stderr.write("""Encountered error '{}' whilst running {}""".format(str(error),
                                                             linter))
                    raise error
276009
def lint(to_lint):
    
    exit_code = 0
    for linter, options in (('pyflakes', []), ('pep8', [])):
        try:
            output = local[linter](*(options + to_lint))
        except commands.ProcessExecutionError as e:
            output = e.stdout

        if output:
            exit_code = 1
            print "{0} Errors:".format(linter)
            print output

    output = hacked_pep257(to_lint)
    if output:
        exit_code = 1
        print "Docstring Errors:".format(linter.upper())
        print output

    sys.exit(exit_code)
592092
def proselint(paths=None, version=None, clean=None, debug=None,
              output_json=None, time=None, demo=None, compact=None):
    """"""
    if time:
        click.echo(timing_test())
        return

    # In debug or clean mode, delete cache & *.pyc files before running.
    if debug or clean:
        clear_cache()

    # Use the demo file by default.
    if demo:
        paths = [demo_file]

    # Expand the list of directories and files.
    filepaths = extract_files(list(paths))

    # Lint the files
    num_errors = 0

    # Use stdin if no paths were specified
    if len(paths) == 0:
        filepaths.append('-')

    for fp in filepaths:
        try:
            if fp == '-':
                fp = '<stdin>'
                f = sys.stdin
            else:
                f = click.open_file(
                    fp, 'r', encoding="utf-8", errors="replace")
            errors = lint(f, debug=debug)
            num_errors += len(errors)
            print_errors(fp, errors, output_json, compact=compact)
        except Exception:
            traceback.print_exc()

    # Return an exit code
    close_cache_shelves()
    if num_errors > 0:
        sys.exit(1)
    else:
        sys.exit(0)
1124216
def process_file(file, report)
      lints = collect_lints(file, linter_selector, config)
      lints.each { |lint| report.add_lint(lint) }
      report.finish_file(file, lints)
    end
895280
def lint(session):
    

    session.install("black", "flake8", *LOCAL_DEPS)
    session.install(".")
    session.run("flake8", os.path.join("google", "cloud", "bigquery"))
    session.run("flake8", "tests")
    session.run("flake8", os.path.join("docs", "snippets.py"))
    session.run("black", "--check", *BLACK_PATHS)
995685
def register_checkers(linter):
    """"""
    linter.register_checker(ModelChecker(linter))
    linter.register_checker(DjangoInstalledChecker(linter))
    linter.register_checker(JsonResponseChecker(linter))
    linter.register_checker(FormChecker(linter))