class RuboCop::RSpec::DescriptionExtractor::CodeObject
Decorator of a YARD code object for working with documented rspec cops
Constants
- RSPEC_COP_CLASS_NAME
- RSPEC_NAMESPACE
- RUBOCOP_COP_CLASS_NAME
Attributes
Public Class Methods
Source
# File lib/rubocop/rspec/description_extractor.rb, line 28 def initialize(yardoc) @yardoc = yardoc end
Public Instance Methods
Source
# File lib/rubocop/rspec/description_extractor.rb, line 42 def configuration { cop_name => { 'Description' => description } } end
Configuration for the documented cop that would live in default.yml
@return [Hash]
Source
# File lib/rubocop/rspec/description_extractor.rb, line 35 def rspec_cop? cop_subclass? && !abstract? && rspec_cop_namespace? end
Test if the YARD code object documents a concrete rspec cop class
@return [Boolean]
Private Instance Methods
Source
# File lib/rubocop/rspec/description_extractor.rb, line 69 def abstract? yardoc.tags.any? { |tag| tag.tag_name.eql?('abstract') } end
Source
# File lib/rubocop/rspec/description_extractor.rb, line 48 def cop_name Object.const_get(documented_constant).cop_name end
Source
# File lib/rubocop/rspec/description_extractor.rb, line 64 def cop_subclass? [RSPEC_COP_CLASS_NAME, RUBOCOP_COP_CLASS_NAME].include?(yardoc.superclass.path) end
Source
# File lib/rubocop/rspec/description_extractor.rb, line 52 def description yardoc.docstring.split("\n\n").first.to_s end
Source
# File lib/rubocop/rspec/description_extractor.rb, line 60 def documented_constant yardoc.to_s end
Source
# File lib/rubocop/rspec/description_extractor.rb, line 56 def rspec_cop_namespace? documented_constant.start_with?(RSPEC_NAMESPACE) end