Class: Lintrunner::CLI
- Inherits:
-
Object
- Object
- Lintrunner::CLI
- Defined in:
- lib/lintrunner/cli.rb
Instance Method Summary collapse
-
#run(args) ⇒ Object
Takes an array of arguments Returns exit code.
Instance Method Details
#run(args) ⇒ Object
Takes an array of arguments Returns exit code
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lintrunner/cli.rb', line 8 def run(args) = Options.new.parse(args) () path = [:path] context = [:context] # If context is different from path that we want to lint, check that it's up to date path != context && is_up_to_date?(context) warnings = [] reporter = initialize_reporter([:reporter], path) config = JSON.parse(File.read(Dir.pwd + "/.lintrunner_config")) include_paths(config["include_paths"]) require_files(config["require"]) config["linters"].each do |name, config| next if config["disabled"] if config["command"] && config["parser"] parser = Lintrunner::Parser.const_get(config["parser"]).new executor = Lintrunner::Executor.new( command: config["command"], parser: parser ) else executor = Lintrunner::Executor.new( plugin: Lintrunner::Plugin.const_get(config["plugin"]) ) end runner = Lintrunner::Runner.const_get(config["runner"]).new( path: path, match: config["match"], executor: executor ) reporter.start(name) results = runner.run(reporter) reporter.finish(results) warnings.concat(results) end exit warnings.empty? ? 0 : 1 end |