lib/rubocop/rspec/description_extractor.rb in rubocop-rspec-2.15.0 vs lib/rubocop/rspec/description_extractor.rb in rubocop-rspec-2.16.0
- old
+ new
@@ -19,25 +19,23 @@
attr_reader :code_objects
# Decorator of a YARD code object for working with documented rspec cops
class CodeObject
- COP_CLASS_NAME = 'RuboCop::Cop::RSpec::Base'
+ RSPEC_COP_CLASS_NAME = 'RuboCop::Cop::RSpec::Base'
+ RUBOCOP_COP_CLASS_NAME = 'RuboCop::Cop::Base'
RSPEC_NAMESPACE = 'RuboCop::Cop::RSpec'
def initialize(yardoc)
@yardoc = yardoc
end
# Test if the YARD code object documents a concrete rspec cop class
#
# @return [Boolean]
def rspec_cop?
- class_documentation? &&
- rspec_cop_namespace? &&
- cop_subclass? &&
- !abstract?
+ cop_subclass? && !abstract? && rspec_cop_namespace?
end
# Configuration for the documented cop that would live in default.yml
#
# @return [Hash]
@@ -53,23 +51,20 @@
def description
yardoc.docstring.split("\n\n").first.to_s
end
- def class_documentation?
- yardoc.type.equal?(:class)
- end
-
def rspec_cop_namespace?
documented_constant.start_with?(RSPEC_NAMESPACE)
end
def documented_constant
yardoc.to_s
end
def cop_subclass?
- yardoc.superclass.path == COP_CLASS_NAME
+ yardoc.superclass.path == RSPEC_COP_CLASS_NAME ||
+ yardoc.superclass.path == RUBOCOP_COP_CLASS_NAME
end
def abstract?
yardoc.tags.any? { |tag| tag.tag_name.eql?('abstract') }
end