Runs all provided linters using the specified config against the given
 file.

 @param file [String] path to file to lint
 @param linter_selector [HamlLint::LinterSelector]
 @param config [HamlLint::Configuration]
546278
def collect_lints(file, linter_selector, config)
      begin
        document = HamlLint::Document.new(File.read(file), file: file, config: config)
      rescue HamlLint::Exceptions::ParseError => e
        return [HamlLint::Lint.new(HamlLint::Linter::Syntax.new(config), file,
                                   e.line, e.to_s, :error)]
      end

      linter_selector.linters_for_file(file).map do |linter|
        linter.run(document)
      end.flatten
    end
805139
def register_linter(linter):
        
        if hasattr(linter, "EXTS") and hasattr(linter, "run"):
            LintFactory.PLUGINS.append(linter)
        else:
            raise LinterException("Linter does not have 'run' method or EXTS variable!")
958513
def _set_linters(self):
        """"""
        if 'linters' in self._config:
            self.user_linters = list(self._parse_cfg_linters())
            self.linters = {linter: self._all_linters[linter]
                            for linter in self.user_linters}
        else:
            self.linters = self._all_linters
1247277
def load(file)
      if file.nil? || !File.exist?(file)
        raise "Can't open #{file}."
      end
      loader = ReVIEW::YAMLLoader.new
      merge_config(@config.deep_merge(loader.load_file(file)))
    end
279933
public static void addFileToClassPath(Path file, Configuration conf)
    throws IOException {
    String classpath = conf.get("mapred.job.classpath.files");
    conf.set("mapred.job.classpath.files", classpath == null ? file.toString()
             : classpath + System.getProperty("path.separator") + file.toString());
    URI uri = file.makeQualified(file.getFileSystem(conf)).toUri();

    addCacheFile(uri, conf);
  }
1315425
def find_config(file)
      path = Pathname(file).expand_path

      while path.parent != path
        config1 = path.join("browserslist")
        return config1.read if config1.exist? && !config1.directory?

        config2 = path.join(".browserslistrc")
        return config2.read if config2.exist? && !config1.directory?

        path = path.parent
      end

      nil
    end
1178001
def config_file_contents
      output = []
      output << HEADING
      output << 'linters:' if linters_with_lints.any?
      linters_with_lints.each do |linter, files|
        output << generate_config_for_linter(linter, files)
      end
      output.join("\n\n")
    end
1227194
def finished_file(file, lints)
      super

      if lints.any?
        lints.each do |lint|
          linters_with_lints[lint.linter.name] |= [lint.filename]
          linters_lint_count[lint.linter.name] += 1
        end
      end
    end
479440
public void load(String file) {
		Context context = factory.enterContext();
		
		try {
			URL url = Thread.currentThread().getContextClassLoader().getResource(file);
			
			if (url == null) {
				logger.debug("Configuration [" + file + "] does not exist");
				return;
			}
			
			File f = new File(url.getPath());
			
			if (f.exists()) {
				logger.info("Loading configuration [" + file + "]");
				context.evaluateReader(scope, new FileReader(f), file.substring(file.lastIndexOf("/") + 1), 1, null);
			}
			
		} catch (Exception e) {
			logger.error("Failed to load configuration [" + file + "]", e);
			throw new UncheckedException(e);
		} finally {
			Context.exit();
		}
	}
602736
public static void doFile(File f)
                              throws Exception {
        // If this is a directory, walk each file/dir in that directory
        if (f.isDirectory()) {
            String files[] = f.list();
            for(int i=0; i < files.length; i++)
                doFile(new File(f, files[i]));
        }

        // otherwise, if this is a groovy file, parse it!
        else if (f.getName().endsWith(".groovy")) {
            System.err.println(" --- "+f.getAbsolutePath());
            // parseFile(f.getName(), new FileInputStream(f));
            SourceBuffer sourceBuffer = new SourceBuffer();
            UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new FileReader(f),sourceBuffer);
            GroovyLexer lexer = new GroovyLexer(unicodeReader);
            unicodeReader.setLexer(lexer);
            parseFile(f.getName(),lexer,sourceBuffer);
        }
    }

    // Here's where we do the real work...
    public static void parseFile(String f, GroovyLexer l, SourceBuffer sourceBuffer)
                                 throws Exception {
        try {
            // Create a parser that reads from the scanner
            GroovyRecognizer parser = GroovyRecognizer.make(l);
            parser.setSourceBuffer(sourceBuffer);
            parser.setFilename(f);
                        
                        if (whitespaceIncluded) {
                            GroovyLexer lexer = parser.getLexer();
                            lexer.setWhitespaceIncluded(true);
                            while (true) {
                                Token t = lexer.nextToken();
                                System.out.println(t);
                                if (t == null || t.getType() == Token.EOF_TYPE)  break;
                            }
                            return;
                        }

            // start parsing at the compilationUnit rule
            parser.compilationUnit();
            
            System.out.println("parseFile "+f+" => "+parser.getAST());

            // do something with the tree
            doTreeAction(f, parser.getAST(), parser.getTokenNames());
        }
736503
function(selector) {
            selector = selector || '';
            selector = Selector._replaceShorthand(Y.Lang.trim(selector)); 
            var token = Selector._getToken(),     // one token per simple selector (left selector holds combinator)
                query = selector, // original query for debug report
                tokens = [],    // array of tokens
                found = false,  // whether or not any matches were found this pass
                match,         // the regex match
                test,
                i, parser;

            /*
                Search for selector patterns, store, and strip them from the selector string
                until no patterns match (invalid selector) or we run out of chars.

                Multiple attributes and pseudos are allowed, in any order.
                for example:
                    'form:first-child[type=button]:not(button)[lang|=en]'
            */
            outer:
            do {
                found = false; // reset after full pass
                for (i = 0; (parser = Selector._parsers[i++]);) {
                    if ( (match = parser.re.exec(selector)) ) { // note assignment
                        if (parser.name !== COMBINATOR ) {
                            token.selector = selector;
                        }
                        selector = selector.replace(match[0], ''); // strip current match from selector
                        if (!selector.length) {
                            token.last = true;
                        }

                        if (Selector._attrFilters[match[1]]) { // convert class to className, etc.
                            match[1] = Selector._attrFilters[match[1]];
                        }

                        test = parser.fn(match, token);
                        if (test === false) { // selector not supported
                            found = false;
                            break outer;
                        } else if (test) {
                            token.tests.push(test);
                        }

                        if (!selector.length || parser.name === COMBINATOR) {
                            tokens.push(token);
                            token = Selector._getToken(token);
                            if (parser.name === COMBINATOR) {
                                token.combinator = Y.Selector.combinators[match[1]];
                            }
                        }
                        found = true;
                    }
                }
            } while (found && selector.length);

            if (!found || selector.length) { // not fully parsed
                tokens = [];
            }
            return tokens;
        }
56159
function lintAllFiles (src, options)
{
    glob(src,
        function (err, files)
        {
            if (err) throw err;

            for (var i = 0, l = files.length; i < l; i++)
            {
                jsHintHelper.lintFile(files[i], options.rules);
            }
        }
    );
}
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
794237
def set_from_config_file(self, filename):
        
        if not os.path.exists(filename):
            raise LintConfigError(u"Invalid file path: {0}".format(filename))
        self._config_path = os.path.abspath(filename)
        try:
            parser = ConfigParser()
            parser.read(filename)

            for section_name in parser.sections():
                for option_name, option_value in parser.items(section_name):
                    self.set_option(section_name, option_name, ustr(option_value))

        except ConfigParserError as e:
            raise LintConfigError(ustr(e))
178058
def run_main(args: argparse.Namespace, do_exit=True) -> None:
    
    if args.init:
        generate()
        return None  # exit after generate instead of starting to lint

    handler = CheckHandler(
        file=args.config_file, out_json=args.json, files=args.files)

    for style in get_stylers():
        handler.run_linter(style())

    for linter in get_linters():
        handler.run_linter(linter())

    for security in get_security():
        handler.run_linter(security())

    for tool in get_tools():
        tool = tool()

        # Only run pypi if everything else passed
        if tool.name == "pypi" and handler.status_code != 0:
            continue

        handler.run_linter(tool)

    if do_exit:
        handler.exit()
    return handler.status_code
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
926854
function Linter(ruleFilePath) {
    if (!ruleFilePath) logger.info("No rule file provided, using default rules");
    this.rules = loadRules(ruleFilePath);
    helper.initLineRulesRegexes(this.rules);
}