Class: RuboCop::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/runner.rb

Overview

This class handles the processing of files, which includes dealing with formatters and letting cops inspect the files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, config_store) ⇒ Runner

Returns a new instance of Runner.


10
11
12
13
14
15
# File 'lib/rubocop/runner.rb', line 10

def initialize(options, config_store)
  @options = options
  @config_store = config_store
  @errors = []
  @aborting = false
end

Instance Attribute Details

#abortingObject (readonly) Also known as: aborting?

Returns the value of attribute aborting


7
8
9
# File 'lib/rubocop/runner.rb', line 7

def aborting
  @aborting
end

#errorsObject (readonly)

Returns the value of attribute errors


7
8
9
# File 'lib/rubocop/runner.rb', line 7

def errors
  @errors
end

Instance Method Details

#abortObject


39
40
41
# File 'lib/rubocop/runner.rb', line 39

def abort
  @aborting = true
end

#run(paths) ⇒ Object


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

def run(paths)
  target_files = find_target_files(paths)

  inspected_files = []
  all_passed = true

  formatter_set.started(target_files)

  target_files.each do |file|
    break if aborting?
    offenses = process_file(file)
    all_passed = false if offenses.any? { |o| considered_failure?(o) }
    inspected_files << file
    break if @options[:fail_fast] && !all_passed
  end

  formatter_set.finished(inspected_files.freeze)
  formatter_set.close_output_files

  all_passed
end