Class: RubocopAutoCorrector::CopFinder
- Inherits:
-
Object
- Object
- RubocopAutoCorrector::CopFinder
- Defined in:
- lib/rubocop_auto_corrector/cop_finder.rb
Instance Attribute Summary collapse
-
#cop_name ⇒ Object
readonly
Returns the value of attribute cop_name.
Instance Method Summary collapse
-
#auto_correctable? ⇒ Boolean
Whether this cop is auto correctable.
- #cop_class_name ⇒ String
- #gem_name ⇒ String
-
#initialize(cop_name) ⇒ CopFinder
constructor
A new instance of CopFinder.
Constructor Details
#initialize(cop_name) ⇒ CopFinder
Returns a new instance of CopFinder.
8 9 10 |
# File 'lib/rubocop_auto_corrector/cop_finder.rb', line 8 def initialize(cop_name) @cop_name = cop_name end |
Instance Attribute Details
#cop_name ⇒ Object (readonly)
Returns the value of attribute cop_name.
5 6 7 |
# File 'lib/rubocop_auto_corrector/cop_finder.rb', line 5 def cop_name @cop_name end |
Instance Method Details
#auto_correctable? ⇒ Boolean
Whether this cop is auto correctable
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop_auto_corrector/cop_finder.rb', line 14 def auto_correctable? Object.new.instance_eval <<-RUBY, __FILE__, __LINE__ + 1 # begin # require 'rubocop-rspec' # rescue LoadError # end # # return ::RuboCop::Cop::RSpec::AlignLeftLetBrace.support_autocorrect? if ::RuboCop::Cop::RSpec::AlignLeftLetBrace.respond_to?(:support_autocorrect?) # ::RuboCop::Cop::RSpec::AlignLeftLetBrace.new.respond_to?(:autocorrect) begin require '#{gem_name}' rescue LoadError end return #{cop_class_name}.support_autocorrect? if #{cop_class_name}.respond_to?(:support_autocorrect?) #{cop_class_name}.new.respond_to?(:autocorrect) RUBY rescue NameError false end |
#cop_class_name ⇒ String
43 44 45 46 |
# File 'lib/rubocop_auto_corrector/cop_finder.rb', line 43 def cop_class_name _, cop_class = rubocop_cop_info cop_class end |
#gem_name ⇒ String
37 38 39 40 |
# File 'lib/rubocop_auto_corrector/cop_finder.rb', line 37 def gem_name gem_name, = rubocop_cop_info gem_name end |