Class: RuboCop::Cop::Force

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/force.rb

Overview

A scaffold for concrete forces.

Direct Known Subclasses

VariableForce

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cops) ⇒ Force

Returns a new instance of Force.


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

def initialize(cops)
  @cops = cops
end

Instance Attribute Details

#copsObject (readonly)

Returns the value of attribute cops


7
8
9
# File 'lib/rubocop/cop/force.rb', line 7

def cops
  @cops
end

Class Method Details

.allObject


9
10
11
# File 'lib/rubocop/cop/force.rb', line 9

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

.force_nameObject


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

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

.inherited(subclass) ⇒ Object


13
14
15
16
# File 'lib/rubocop/cop/force.rb', line 13

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

Instance Method Details

#investigate(_processed_source) ⇒ Object


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

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

#nameObject


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

def name
  self.class.force_name
end

#run_hook(method_name, *args) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/rubocop/cop/force.rb', line 30

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

    cop.send(method_name, *args)
  end
end