Class: RubocopChallenger::Rubocop::Yardoc

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop_challenger/rubocop/yardoc.rb

Overview

To read YARD style documentation from rubocop gem source code

Instance Method Summary collapse

Constructor Details

#initialize(cop) ⇒ Yardoc

Returns a new instance of Yardoc.



7
8
9
10
11
# File 'lib/rubocop_challenger/rubocop/yardoc.rb', line 7

def initialize(cop)
  load_rubocop_gems!
  @cop_class = find_cop_class(cop)
  load_yardoc!
end

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/rubocop_challenger/rubocop/yardoc.rb', line 13

def description
  yardoc.docstring
end

#examplesObject



17
18
19
# File 'lib/rubocop_challenger/rubocop/yardoc.rb', line 17

def examples
  yardoc.tags('example').map { |tag| [tag.name, tag.text] }
end

#safe_autocorrect?Boolean

Indicates whether the autocorrect a cop does is safe (equivalent) by design. If a cop is unsafe its autocorrect automatically becomes unsafe as well.

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/rubocop_challenger/rubocop/yardoc.rb', line 25

def safe_autocorrect?
  config = RuboCop::ConfigLoader.default_configuration
  cop_class.new(config).safe_autocorrect?
end