class RuboCop::EightyFourCodes::DescriptionExtractor::CodeObject
Decorator of a YARD code object for working with documented rspec cops
Constants
- RSPEC_NAMESPACE
Attributes
yardoc[R]
Public Class Methods
new(yardoc)
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 24 def initialize(yardoc) @yardoc = yardoc end
Public Instance Methods
configuration()
click to toggle source
Configuration for the documented cop that would live in default.yml
@return [Hash]
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 38 def configuration { cop_name => { 'Description' => description } } end
rspec_cop?()
click to toggle source
Test if the YARD code object documents a concrete rspec cop class
@return [Boolean]
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 31 def rspec_cop? class_documentation? && rspec_cop_namespace? && !abstract? end
Private Instance Methods
abstract?()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 64 def abstract? yardoc.tags.any? { |tag| tag.tag_name.eql?('abstract') } end
class_documentation?()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 52 def class_documentation? yardoc.type.equal?(:class) end
cop_name()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 44 def cop_name Object.const_get(documented_constant).cop_name end
description()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 48 def description yardoc.docstring.split("\n\n").first.to_s end
documented_constant()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 60 def documented_constant yardoc.to_s end
rspec_cop_namespace?()
click to toggle source
# File lib/rubocop/eighty_four_codes/description_extractor.rb, line 56 def rspec_cop_namespace? documented_constant.start_with?(RSPEC_NAMESPACE) end