Class: RuboCop::Cop::Commissioner
- Inherits:
-
Object
- Object
- RuboCop::Cop::Commissioner
- Includes:
- Node::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 Node::Traversal
Node::Traversal::MANY_CHILD_NODES, Node::Traversal::NO_CHILD_NODES, Node::Traversal::ONE_CHILD_NODE, Node::Traversal::SECOND_CHILD_ONLY
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cops, forces = [], options = {}) ⇒ Commissioner
constructor
A new instance of Commissioner.
- #investigate(processed_source) ⇒ Object
Methods included from Node::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.
17 18 19 20 21 22 23 24 |
# File 'lib/rubocop/cop/commissioner.rb', line 17 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.
11 12 13 |
# File 'lib/rubocop/cop/commissioner.rb', line 11 def errors @errors end |
Class Method Details
.callback_methods ⇒ Object
13 14 15 |
# File 'lib/rubocop/cop/commissioner.rb', line 13 def self.callback_methods Parser::Meta::NODE_TYPES.map { |type| :"on_#{type}" } end |
Instance Method Details
#investigate(processed_source) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubocop/cop/commissioner.rb', line 52 def investigate(processed_source) reset_errors remove_irrelevant_cops(processed_source.buffer.name) reset_callbacks prepare(processed_source) invoke_custom_processing(@cops, processed_source) invoke_custom_processing(@forces, processed_source) walk(processed_source.ast) if processed_source.ast @cops.flat_map(&:offenses) end |