Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Commissioner

Commissioner class is responsible for processing the AST and delegating work to the specified cops.

Attributes

errors[R]

Public Class Methods

call_super(callback) click to toggle source

Methods that are not defined in Parser::AST::Processor won't have a `super` to call. So we should not attempt to invoke `super` when defining them.

# File lib/rubocop/cop/commissioner.rb, line 22
def self.call_super(callback)
  if METHODS_NOT_DEFINED_IN_PARSER_PROCESSOR.include?(callback)
    ''
  else
    'super'
  end
end
callback_methods() click to toggle source
# File lib/rubocop/cop/commissioner.rb, line 13
def self.callback_methods
  Parser::AST::Processor.instance_methods.select do |method|
    method.to_s =~ /^on_/
  end + METHODS_NOT_DEFINED_IN_PARSER_PROCESSOR
end
new(cops, forces, options = {}) click to toggle source
# File lib/rubocop/cop/commissioner.rb, line 30
def initialize(cops, forces, options = {})
  @cops = cops
  @forces = forces
  @options = options
  reset_errors
end

Public Instance Methods

investigate(processed_source) click to toggle source
# File lib/rubocop/cop/commissioner.rb, line 52
def investigate(processed_source)
  reset_errors
  prepare(processed_source)
  invoke_custom_processing(@cops, processed_source)
  invoke_custom_processing(@forces, processed_source)
  process(processed_source.ast) if processed_source.ast
  @cops.each_with_object([]) do |cop, offenses|
    filename = processed_source.buffer.name
    # ignore files that are of no interest to the cop in question
    offenses.concat(cop.offenses) if cop.relevant_file?(filename)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.