Class: Rubocop::FileInspector
- Inherits:
-
Object
- Object
- Rubocop::FileInspector
- Defined in:
- lib/rubocop/file_inspector.rb
Overview
This class handles the processing of files, which includes dealing with formatters and letting cops inspect the files.
Instance Method Summary collapse
- #display_error_summary ⇒ Object
-
#initialize(options) ⇒ FileInspector
constructor
A new instance of FileInspector.
-
#process_files(target_files, config_store) ⇒ Object
Takes a block which it calls once per inspected file.
Constructor Details
#initialize(options) ⇒ FileInspector
Returns a new instance of FileInspector.
7 8 9 10 |
# File 'lib/rubocop/file_inspector.rb', line 7 def initialize() @options = @errors = [] end |
Instance Method Details
#display_error_summary ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/file_inspector.rb', line 34 def display_error_summary return if @errors.empty? plural = @errors.count > 1 ? 's' : '' warn "\n#{@errors.count} error#{plural} occurred:".color(:red) @errors.each { |error| warn error } warn 'Errors are usually caused by RuboCop bugs.' warn 'Please, report your problems to RuboCop\'s issue tracker.' warn 'Mention the following information in the issue report:' warn Rubocop::Version.version(true) end |
#process_files(target_files, config_store) ⇒ Object
Takes a block which it calls once per inspected file. The block shall return true if the caller wants to break the loop early.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/file_inspector.rb', line 14 def process_files(target_files, config_store) target_files.each(&:freeze).freeze inspected_files = [] any_failed = false formatter_set.started(target_files) target_files.each do |file| break if yield offenses = process_file(file, config_store) any_failed = true unless offenses.empty? inspected_files << file end formatter_set.finished(inspected_files.freeze) formatter_set.close_output_files any_failed end |