Execute lint check against PhingFile or a FileSet
189542
public function main()
    {
        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        if (empty($this->executable)) {
            throw new BuildException("Missing the 'executable' attribute");
        }

        if ($this->file instanceof PhingFile) {
            $this->lint($this->file->getPath());
        } else { // process filesets
            $project = $this->getProject();
            foreach ($this->filesets as $fs) {
                $ds = $fs->getDirectoryScanner($project);
                $files = $ds->getIncludedFiles();
                $dir = $fs->getDir($this->project)->getPath();
                foreach ($files as $file) {
                    $this->lint($dir . DIRECTORY_SEPARATOR . $file);
                }
            }
        }

        // write list of 'bad files' to file (if specified)
        if ($this->tofile) {
            $writer = new FileWriter($this->tofile);

            foreach ($this->badFiles as $file => $messages) {
                foreach ($messages as $msg) {
                    $writer->write($file . "=" . $msg . PHP_EOL);
                }
            }

            $writer->close();
        }

        if ($this->haltOnFailure && $this->hasErrors) {
            throw new BuildException(
                'Syntax error(s) in JS files:' . implode(
                    ', ',
                    array_keys($this->badFiles)
                )
            );
        }
        if ($this->haltOnWarning && $this->hasWarnings) {
            throw new BuildException(
                'Syntax warning(s) in JS files:' . implode(
                    ', ',
                    array_keys($this->badFiles)
                )
            );
        }
    }
104963
function lintFiles (src)
{
    gulp.src(src)
        .pipe(scssLint({
            config: __dirname + "/../config/scss-lint.yml",
            customReport: issueCountReporter
        }))
        .on('error', function (error)
        {
            gulpUtil.log(gulpUtil.colors.red('An error has occurred while executing scss-lint: ' + error.message));
        })
        .on('end', reportTotalIssueCount);
}
989144
def find_lints(ruby, source_map)
      rubocop = ::RuboCop::CLI.new

      filename =
        if document.file
          "#{document.file}.rb"
        else
          'ruby_script.rb'
        end

      with_ruby_from_stdin(ruby) do
        extract_lints_from_offenses(lint_file(rubocop, filename), source_map)
      end
    end
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)
320910
def run_linter(self, linter) -> None:
        """"""
        self.current = linter.name

        if (linter.name not in self.parser["all"].as_list("linters")
                or linter.base_pyversion > sys.version_info):  # noqa: W503
            return

        if any(x not in self.installed for x in linter.requires_install):
            raise ModuleNotInstalled(linter.requires_install)

        linter.add_output_hook(self.out_func)
        linter.set_config(self.fn, self.parser[linter.name])
        linter.run(self.files)
        self.status_code = self.status_code or linter.status_code
1036441
def lint(commit = nil)
      files = pronto(commit)
      return if files.empty?

      markdown offenses_message(files)
    end
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
850959
def _debug_linter_status(linter, filename, show_lint_files):
    """"""
    if show_lint_files:
        print("{linter}: {filename}".format(linter=linter, filename=filename))
748438
def file_matches_regexps(filename, patterns):
    """"""
    return any(re.match(pat, filename) for pat in patterns)
1150540
def _check_file(parameters):
    """"""
    (filename, args) = parameters

    if filename == '-':
        contents = sys.stdin.read()
    else:
        with contextlib.closing(
            docutils.io.FileInput(source_path=filename)
        ) as input_file:
            contents = input_file.read()

    args = load_configuration_from_file(
        os.path.dirname(os.path.realpath(filename)), args)

    ignore_directives_and_roles(args.ignore_directives, args.ignore_roles)

    for substitution in args.ignore_substitutions:
        contents = contents.replace('|{}|'.format(substitution), 'None')

    ignore = {
        'languages': args.ignore_language,
        'messages': args.ignore_messages,
    }
    all_errors = []
    for error in check(contents,
                       filename=filename,
                       report_level=args.report,
                       ignore=ignore,
                       debug=args.debug):
        all_errors.append(error)
    return (filename, all_errors)
13478
def lint():
    """"""
    py_files = subprocess.check_output("git ls-files")
    if PY3:
        py_files = py_files.decode()
    py_files = [x for x in py_files.split() if x.endswith('.py')]
    py_files = ' '.join(py_files)
    sh("%s -m flake8 %s" % (PYTHON, py_files), nolog=True)
1309709
def _run_lint_on_file(file_path,
                      linter_functions,
                      tool_options,
                      fix_what_you_can):
    
    with io.open(file_path, "r+", encoding="utf-8") as found_file:
        file_contents = found_file.read()
        file_lines = file_contents.splitlines(True)
        try:
            errors = lint(file_path[len(os.getcwd()) + 1:],
                          file_contents,
                          linter_functions,
                          **tool_options)
        except RuntimeError as err:
            msg = ("""RuntimeError in processing {0} - {1}""".format(file_path, str(err)))
            errors = [("polysquarelinter/failure",
                       LinterFailure(msg, 0, None))]

        if fix_what_you_can:
            for error_index, error in enumerate(errors):
                if error[1].replacement is not None:
                    _apply_replacement(error, found_file, file_lines)
                    errors[error_index] = (error[0],
                                           LinterFailure(error[1].description +
                                                         " ... FIXED",
                                                         error[1].line,
                                                         error[1].replacement))
                    break

        return [FileLinterFailure(file_path, e) for e in errors]
1171377
def lint(files, inline_mode = false, options = {})
      final_options = options.merge(json: true)

      issues = files
               .map { |file| Shellwords.escape(file) }
               .map { |file| `hlint lint #{file} #{to_hlint_options(final_options)} 2>/dev/null` }
               .reject { |s| s == '' }
               .map { |lint_result| JSON.parse(lint_result).flatten }
               .flatten

      self.suggestions = issues.select { |issue| issue['severity'] == 'Suggestion' }
      self.warnings = issues.select { |issue| issue['severity'] == 'Warning' }
      self.errors = issues.select { |issue| issue['severity'] == 'Error' }

      if inline_mode
        # Reprt with inline comment
        send_inline_comment(suggestions, 'warn')
        send_inline_comment(warnings, 'warn')
        send_inline_comment(errors, 'fail')

      else
        # Report if any suggestions, warnings or errors
        if suggestions.count > 0 || warnings.count > 0 || errors.count > 0
          message = "### hlint found issues\n\n"
          message << markdown_issues(warnings, 'Suggestions') unless suggestions.empty?
          message << markdown_issues(warnings, 'Warnings') unless warnings.empty?
          message << markdown_issues(errors, 'Errors') unless errors.empty?
          markdown message
        end
      end
    end
883261
public function lintFileSets() {
    $this->say("Validating twig syntax for all custom modules and themes...");

    /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */
    $fileset_manager = $this->getContainer()->get('filesetManager');
    $fileset_ids = $this->getConfigValue('validate.twig.filesets');
    $filesets = $fileset_manager->getFilesets($fileset_ids);
    $this->executeTwigLintCommandAgainstFilesets($filesets);
  }
196792
def _run_markdownlint(matched_filenames, show_lint_files):
    """"""
    from prospector.message import Message, Location

    for filename in matched_filenames:
        _debug_linter_status("mdl", filename, show_lint_files)

    try:
        proc = subprocess.Popen(["mdl"] + matched_filenames,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        lines = proc.communicate()[0].decode().splitlines()
    except OSError as error:
        if error.errno == errno.ENOENT:
            return []

    lines = [
        re.match(r"([\w\-.\/\\ ]+)\:([0-9]+)\: (\w+) (.+)", l).groups(1)
        for l in lines
    ]
    return_dict = dict()
    for filename, lineno, code, msg in lines:
        key = _Key(filename, int(lineno), code)
        loc = Location(filename, None, None, int(lineno), 0)
        return_dict[key] = Message("markdownlint", code, loc, msg)

    return return_dict
794609
def _run_prospector_on(filenames,
                       tools,
                       disabled_linters,
                       show_lint_files,
                       ignore_codes=None):
    
    from prospector.run import Prospector, ProspectorConfig

    assert tools

    tools = list(set(tools) - set(disabled_linters))
    return_dict = dict()
    ignore_codes = ignore_codes or list()

    # Early return if all tools were filtered out
    if not tools:
        return return_dict

    # pylint doesn't like absolute paths, so convert to relative.
    all_argv = (["-F", "-D", "-M", "--no-autodetect", "-s", "veryhigh"] +
                ("-t " + " -t ".join(tools)).split(" "))

    for filename in filenames:
        _debug_linter_status("prospector", filename, show_lint_files)

    with _custom_argv(all_argv + [os.path.relpath(f) for f in filenames]):
        prospector = Prospector(ProspectorConfig())
        prospector.execute()
        messages = prospector.get_messages() or list()
        for message in messages:
            message.to_absolute_path(os.getcwd())
            loc = message.location
            code = message.code

            if code in ignore_codes:
                continue

            key = _Key(loc.path, loc.line, code)
            return_dict[key] = message

    return return_dict
867742
def lint():
    
    from pylint import lint as linter

    # report according to file extension
    reporters = {
        ".html": linter.HTMLReporter,
        ".log": linter.ParseableTextReporter,
        ".txt": linter.TextReporter,
    }

    lint_build_dir = path("build/lint")
    lint_build_dir.exists() or lint_build_dir.makedirs()

    argv = []
    rcfile = options.lint.get("rcfile")
    if not rcfile and path("pylint.cfg").exists():
        rcfile = "pylint.cfg"
    if rcfile:
        argv += ["--rcfile", os.path.abspath(rcfile)]
    if options.lint.get("msg_only", False):
        argv += ["-rn"]
    argv += [
        "--import-graph", (lint_build_dir / "imports.dot").abspath(),
    ]
    argv += toplevel_packages()

    sys.stderr.write("Running %s::pylint '%s'\n" % (sys.argv[0], "' '".join(argv)))
    outfile = options.lint.get("output", None)
    if outfile:
        outfile = os.path.abspath(outfile)

    try:
        with pushd("src" if path("src").exists() else "."):
            if outfile:
                reporterClass = reporters.get(path(outfile).ext, linter.TextReporter)
                sys.stderr.write("Writing output to %r\n" % (str(outfile),))
                linter.Run(argv, reporter=reporterClass(open(outfile, "w")))
            else:
                linter.Run(argv)
    except SystemExit, exc:
        if not exc.code:
            sys.stderr.write("paver::lint - No problems found.\n")
        elif exc.code & 32:
            # usage error (internal error in this code)
            sys.stderr.write("paver::lint - Usage error, bad arguments %r?!\n" % (argv,))
            raise
        else:
            bits = {
                1: "fatal",
                2: "error",
                4: "warning",
                8: "refactor",
                16: "convention",
            }
            sys.stderr.write("paver::lint - Some %s message(s) issued.\n" % (
                ", ".join([text for bit, text in bits.items() if exc.code & bit])
            ))
            if exc.code & 3:
                sys.stderr.write("paver::lint - Exiting due to fatal / error message.\n")
                raise