Execute lint check against PhingFile or a FileSet
434482
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 ($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();
        }

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

        // save list of 'bad files' with errors to property errorproperty (if specified)
        if ($this->errorProperty) {
            $this->project->setProperty($this->errorProperty, $message);
        }

        if (!empty($this->cache)) {
            $this->cache->commit();
        }

        if ($this->haltOnFailure && $this->hasErrors) {
            throw new BuildException('Syntax error(s) in PHP files: ' . $message);
        }
    }
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)
1198300
def run_linter_on_file?(config, linter, file)
      linter_config = config.for_linter(linter)

      if linter_config['include'].any? &&
         !HamlLint::Utils.any_glob_matches?(linter_config['include'], file)
        return false
      end

      if HamlLint::Utils.any_glob_matches?(linter_config['exclude'], file)
        return false
      end

      true
    end
442845
def generate_config_for_linter(linter, files)
      [].tap do |output|
        output << "  # Offense count: #{linters_lint_count[linter]}"
        output << "  #{linter}:"
        # disable the linter when there are many files with offenses.
        # exclude the affected files otherwise.
        if files.count > exclude_limit
          output << '    enabled: false'
        else
          output << '    exclude:'
          files.each do |filename|
            output << %{      - "#{filename}"}
          end
        end
      end.join("\n")
    end
707073
def lint():
    
    path = os.path.realpath(os.getcwd())
    cmd = 'flake8 %s' % path
    opt = ''
    print(">>> Linting codebase with the following command: %s %s" % (cmd, opt))

    try:
        return_code = call([cmd, opt], shell=True)
        if return_code < 0:
            print(">>> Terminated by signal", -return_code, file=sys.stderr)
        elif return_code != 0:
            sys.exit('>>> Lint checks failed')
        else:
            print(">>> Lint checks passed", return_code, file=sys.stderr)
    except OSError as e:
        print(">>> Execution failed:", e, file=sys.stderr)
245478
def run_swiftlint(files, lint_all_files, options, additional_swiftlint_args)
      if lint_all_files
        result = swiftlint.lint(options, additional_swiftlint_args)
        if result == ''
          {}
        else
          JSON.parse(result).flatten
        end
      else
        files
          .map { |file| options.merge(path: file) }
          .map { |full_options| swiftlint.lint(full_options, additional_swiftlint_args) }
          .reject { |s| s == '' }
          .map { |s| JSON.parse(s).flatten }
          .flatten
      end
    end
1141263
void fileReadCheck(String filePath) {
        File potentialFile = new File(filePath);
        String canonicalPath;
        try {
            canonicalPath = potentialFile.getCanonicalPath();
        } catch (IOException e) {
            error("Error getting canonical path", e);
            throw getException(filePath);
        }

        if (forbiddenReadFiles.stream().anyMatch(canonicalPath::startsWith)) {
            throw getException(filePath);
        }
    }
1036441
def lint(commit = nil)
      files = pronto(commit)
      return if files.empty?

      markdown offenses_message(files)
    end
469220
function lint (files) {
  const stream = gulp.src(files)
  .pipe($.plumber())
  .pipe($.eslint())
  .pipe($.eslint.format())
  if (process.env.NODE_ENV === 'production') {
    stream.pipe($.eslint.failOnError())
  }
  stream.on('error', onError)
  return stream
}
613729
function validateFileset(fileset, setter) {
    if (Array.isArray(fileset)) {
        async.each(fileset, function(path, callback) {
            if (typeof path === 'string') {
                callback();
            } else {
                callback(util.format('Invalid path: %s', path));
            }
        }, function(err) {
            if (err) {
                console.log(chalk.red(err));
            } else {
                setter(fileset);
            }
        });
    } else {
        console.log(chalk.red('Fileset is not an array: %j'), fileset);
    }
}
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)
1229560
def lint(click_ctx: click.Context, run_id: int, filenames: List[str]) -> None:
    """"""
    ctx = click_ctx.obj
    require_option(click_ctx, "repository")

    paths = [Path(p).resolve() for p in filenames]
    root = Path(ctx.repository).resolve()
    relative = [str(Path(f).relative_to(root)) for f in paths]

    with ctx.database.make_session() as session:
        instances = (
            session.query(
                IssueInstance.filename,
                IssueInstance.location,
                SharedText.contents,
                Issue.code,
            )
            .filter(IssueInstance.run_id == run_id)
            .filter(IssueInstance.filename.in_(relative))
            .join(Issue, Issue.id == IssueInstance.issue_id)
            .join(SharedText, SharedText.id == IssueInstance.message_id)
            .all()
        )

    with ctx.database.make_session() as session:
        frames = (
            session.query(
                CallerText.contents.label("caller"),
                CalleeText.contents.label("callee"),
                FilenameText.contents.label("filename"),
                TraceFrame.callee_location,
                TraceFrame.kind,
                TraceFrame.callee_port,
                TraceFrame.caller_port,
            )
            .filter(TraceFrame.run_id == run_id)
            .join(FilenameText, FilenameText.id == TraceFrame.filename_id)
            .filter(FilenameText.contents.in_(relative))
            .join(CallerText, CallerText.id == TraceFrame.caller_id)
            .join(CalleeText, CalleeText.id == TraceFrame.callee_id)
            .all()
        )

    def entry(filename, code, message, location):
        return {
            "filename": str(root / filename),
            "code": code,
            "message": message,
            "line": location.line_no,
            "col": location.begin_column,
            "length": location.begin_column + location.end_column + 1,
        }

    lints = [
        entry(i.filename, str(i.code), i.contents, i.location) for i in instances
    ] + [
        entry(
            i.filename,
            i.kind.name,
            f"{i.caller}:{i.caller_port} -> {i.callee}->{i.callee_port}",
            i.callee_location,
        )
        for i in frames
    ]

    for l in sorted(lints, key=itemgetter("filename", "line", "code", "col")):
        click.echo(json.dumps(l))
314503
function lintMarkdown (body, file) {
  var codeBlocks = parseMarkdown(body);

  didLogFileBreak = false;

  var failedCodeBlocks = _.reject(_.compact(codeBlocks), function (codeBlock) {
    return validateCodeBlock(codeBlock, file);
  });

  numFilesToParse--;

  if (failedCodeBlocks.length === 0) {
    if (program.verbose) {
      console.log('Markdown passed linting for '.green + file.blue.bold + '\n');
    } else if (numFilesToParse === 0) {
      console.log('All markdown files passed linting'.green);
    }
  } else {
    if (numFailedFiles % 2 === 0) {
    console.log('Markdown failed linting for '.red + file.yellow);
    } else {
      console.log('Markdown failed linting for '.red + file.blue);
    }
    numFailedFiles++;
    console.log('');
  }
}
1091134
def check(args, source_code, filename=None, options=None):
    """"""
    if args is None:
        return []
    if options is not None:
        args += options
    if any(['pyflakes' in arg for arg in args]):
        #  Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)
        #  Note: this code is not used right now as it is faster to invoke 
        #  pyflakes in current Python interpreter (see `check_with_pyflakes` 
        #  function above) than calling it through a subprocess
        source_code += '\n'
    if filename is None:
        # Creating a temporary file because file does not exist yet 
        # or is not up-to-date
        tempfd = tempfile.NamedTemporaryFile(suffix=".py", delete=False)
        tempfd.write(source_code)
        tempfd.close()
        args.append(tempfd.name)
    else:
        args.append(filename)
    cmd = args[0]
    cmdargs = args[1:]
    proc = programs.run_program(cmd, cmdargs)
    output = proc.communicate()[0].strip().decode().splitlines()
    if filename is None:
        os.unlink(tempfd.name)
    results = []
    coding = encoding.get_coding(source_code)
    lines = source_code.splitlines()
    for line in output:
        lineno = int(re.search(r'(\:[\d]+\:)', line).group()[1:-1])
        try:
            text = to_text_string(lines[lineno-1], coding)
        except TypeError:
            text = to_text_string(lines[lineno-1])
        except UnicodeDecodeError:
            # Needed to handle UnicodeDecodeError and force the use
            # of chardet to detect enconding. See issue 6970
            coding = encoding.get_coding(source_code, force_chardet=True)
            text = to_text_string(lines[lineno-1], coding)
        if 'analysis:ignore' not in text:
            message = line[line.find(': ')+2:]
            results.append((message, lineno))
    return results
1189603
function lint() {
  var errorsFound = false;
  var stream = gulp.src(config.lintGlobs);

  if (isWatching) {
    stream = stream.pipe(watcher());
  }

  if (argv.fix) {
    options.fix = true;
  }

  return stream.pipe(eslint(options))
    .pipe(eslint.formatEach('stylish', function(msg) {
      errorsFound = true;
      util.log(util.colors.red(msg));
    }))
    .pipe(gulpIf(isFixed, gulp.dest('.')))
    .pipe(eslint.failAfterError())
    .on('end', function() {
      if (errorsFound && !options.fix) {
        util.log(util.colors.blue('Run `gulp lint --fix` to automatically ' +
            'fix some of these lint warnings/errors. This is a destructive ' +
            'operation (operates on the file system) so please make sure ' +
            'you commit before running.'));
      }
    });
}
335285
def lint_files(self, files):
        
        all_violations = []
        for filename in files:
            with open(filename, 'r') as f:
                content = f.read()
                violations = self.lint(content)
                all_violations.extend(violations)
                for e in violations:
                    print("{0}:{1}: {2} {3}".format(filename, e.line_nr, e.rule_id, e.message))
        return len(all_violations)
982032
def pylint_check(files):
    # type: (List[str]) -> int
    
    files = fs.wrap_paths(files)
    cfg_path = conf.get_path('lint.pylint_cfg', 'ops/tools/pylint.ini')
    pylint_cmd = 'pylint --rcfile {} {}'.format(cfg_path, files)

    return shell.run(pylint_cmd, exit_on_error=False).return_code