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.
Constant Summary
Constants included from AST::Traversal
AST::Traversal::MANY_CHILD_NODES, AST::Traversal::NO_CHILD_NODES, AST::Traversal::ONE_CHILD_NODE, AST::Traversal::SECOND_CHILD_ONLY
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) ⇒ Object
Methods included from AST::Traversal
#on_block, #on_case, #on_casgn, #on_class, #on_const, #on_def, #on_defs, #on_if, #on_op_asgn, #on_send, #on_while, #walk
Constructor Details
#initialize(cops, forces = [], options = {}) ⇒ Commissioner
Returns a new instance of Commissioner.
12 13 14 15 16 17 18 19 |
# File 'lib/rubocop/cop/commissioner.rb', line 12 def initialize(cops, forces = [], = {}) @cops = cops @forces = forces @options = @callbacks = {} reset_errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'lib/rubocop/cop/commissioner.rb', line 10 def errors @errors end |
Instance Method Details
#investigate(processed_source) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubocop/cop/commissioner.rb', line 37 def investigate(processed_source) reset_errors remove_irrelevant_cops(processed_source.file_path) reset_callbacks prepare(processed_source) invoke_custom_processing(@cops, processed_source) invoke_custom_processing(@forces, processed_source) walk(processed_source.ast) unless processed_source.blank? invoke_custom_post_walk_processing(@cops, processed_source) @cops.flat_map(&:offenses) end |