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
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/file_inspector.rb', line 37 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 33 34 35 |
# 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 if offenses.any? do |o| o.severity >= fail_level end inspected_files << file end formatter_set.finished(inspected_files.freeze) formatter_set.close_output_files any_failed end |