Class: RuboCop::Cop::Force
- Inherits:
-
Object
- Object
- RuboCop::Cop::Force
- Defined in:
- lib/rubocop/cop/force.rb
Overview
A scaffold for concrete forces.
Direct Known Subclasses
Defined Under Namespace
Classes: HookError
Instance Attribute Summary collapse
-
#cops ⇒ Object
readonly
Returns the value of attribute cops.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cops) ⇒ Force
constructor
A new instance of Force.
- #investigate(_processed_source) ⇒ Object
- #name ⇒ Object
- #run_hook(method_name, *args) ⇒ Object
Constructor Details
#initialize(cops) ⇒ Force
Returns a new instance of Force.
32 33 34 |
# File 'lib/rubocop/cop/force.rb', line 32 def initialize(cops) @cops = cops end |
Instance Attribute Details
#cops ⇒ Object (readonly)
Returns the value of attribute cops.
17 18 19 |
# File 'lib/rubocop/cop/force.rb', line 17 def cops @cops end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/rubocop/cop/force.rb', line 19 def self.all @all ||= [] end |
.force_name ⇒ Object
28 29 30 |
# File 'lib/rubocop/cop/force.rb', line 28 def self.force_name name.split('::').last end |
.inherited(subclass) ⇒ Object
23 24 25 26 |
# File 'lib/rubocop/cop/force.rb', line 23 def self.inherited(subclass) super all << subclass end |
Instance Method Details
#investigate(_processed_source) ⇒ Object
50 51 52 |
# File 'lib/rubocop/cop/force.rb', line 50 def investigate(_processed_source) # Do custom processing and invoke #run_hook at arbitrary timing. end |
#name ⇒ Object
36 37 38 |
# File 'lib/rubocop/cop/force.rb', line 36 def name self.class.force_name end |
#run_hook(method_name, *args) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# 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 |