Method: RuboCop::CLI#run

Defined in:
lib/rubocop/cli.rb

#run(args = ARGV) ⇒ Fixnum

Entry point for the application logic. Here we do the command line arguments processing and inspect the target files

Returns:

  • (Fixnum)

    UNIX exit code



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubocop/cli.rb', line 20

def run(args = ARGV)
  @options, paths = Options.new.parse(args)
  act_on_options

  runner = Runner.new(@options, @config_store)
  trap_interrupt(runner)
  all_passed = runner.run(paths)
  display_error_summary(runner.errors)

  all_passed && !runner.aborting? && runner.errors.empty? ? 0 : 1
rescue Cop::AmbiguousCopName => e
  $stderr.puts "Ambiguous cop name #{e.message} needs namespace " \
               'qualifier.'
  return 1
rescue StandardError, SyntaxError => e
  $stderr.puts e.message
  $stderr.puts e.backtrace
  return 1
end