123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Cop::Force

Relationships & Source Files
Namespace Children
Exceptions:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/rubocop/cop/force.rb

Overview

A scaffold for concrete forces.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(cops) ⇒ Force

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 32

def initialize(cops)
  @cops = cops
end

Class Method Details

.all

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 19

def self.all
  @all ||= []
end

.force_name

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 28

def self.force_name
  name.split('::').last
end

.inherited(subclass)

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 23

def self.inherited(subclass)
  super
  all << subclass
end

Instance Attribute Details

#cops (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 17

attr_reader :cops

Instance Method Details

#investigate(_processed_source)

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 50

def investigate(_processed_source)
  # Do custom processing and invoke #run_hook at arbitrary timing.
end

#name

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 36

def name
  self.class.force_name
end

#run_hook(method_name, *args)

[ GitHub ]

  
# File 'lib/rubocop/cop/force.rb', line 40

def run_hook(method_name, *args)
  cops.each do |cop|
    next unless cop.respond_to?(method_name)

    cop.public_send(method_name, *args)
  rescue StandardError
    raise HookError, cop
  end
end