Class: RuboCop::Cop::Commissioner
- Inherits:
-
Object
- Object
- RuboCop::Cop::Commissioner
- Includes:
- AST::Traversal
- Defined in:
- lib/rubocop/cop/commissioner.rb
Overview
Commissioner class is responsible for processing the AST and delegating work to the specified cops.
Defined Under Namespace
Classes: InvestigationReport
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(cops, forces = [], options = {}) ⇒ Commissioner
constructor
A new instance of Commissioner.
- #investigate(processed_source, offset: 0, original: processed_source) ⇒ InvestigationReport
Constructor Details
#initialize(cops, forces = [], options = {}) ⇒ Commissioner
Returns a new instance of Commissioner.
44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/commissioner.rb', line 44 def initialize(cops, forces = [], = {}) @cops = cops @forces = forces @options = initialize_callbacks reset end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
42 43 44 |
# File 'lib/rubocop/cop/commissioner.rb', line 42 def errors @errors end |
Instance Method Details
#investigate(processed_source, offset: 0, original: processed_source) ⇒ InvestigationReport
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rubocop/cop/commissioner.rb', line 79 def investigate(processed_source, offset: 0, original: processed_source) reset begin_investigation(processed_source, offset: offset, original: original) if processed_source.valid_syntax? invoke(:on_new_investigation, @cops) invoke_with_argument(:investigate, @forces, processed_source) walk(processed_source.ast) unless @cops.empty? invoke(:on_investigation_end, @cops) else invoke(:on_other_file, @cops) end reports = @cops.map { |cop| cop.send(:complete_investigation) } InvestigationReport.new(processed_source, reports, @errors) end |