Class: RuboCop::RSpec::DescriptionExtractor::CodeObject

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/rspec/description_extractor.rb

Overview

Decorator of a YARD code object for working with documented rspec cops

Constant Summary collapse

COP_CLASS_NAMES =
%w[RuboCop::Cop RuboCop::Cop::RSpec::Cop].freeze
RSPEC_NAMESPACE =
'RuboCop::Cop::RSpec'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(yardoc) ⇒ CodeObject

Returns a new instance of CodeObject.



25
26
27
# File 'lib/rubocop/rspec/description_extractor.rb', line 25

def initialize(yardoc)
  @yardoc = yardoc
end

Instance Method Details

#configurationHash

Configuration for the documented cop that would live in default.yml

Returns:

  • (Hash)


42
43
44
# File 'lib/rubocop/rspec/description_extractor.rb', line 42

def configuration
  { cop_name => { 'Description' => description } }
end

#rspec_cop?Boolean

Test if the YARD code object documents a concrete rspec cop class

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/rubocop/rspec/description_extractor.rb', line 32

def rspec_cop?
  class_documentation? &&
    rspec_cop_namespace? &&
    cop_subclass? &&
    !abstract?
end