lib/rubocop/cop/rspec/described_class.rb in rubocop-rspec-2.25.0 vs lib/rubocop/cop/rspec/described_class.rb in rubocop-rspec-2.26.0
- old
+ new
@@ -61,11 +61,11 @@
DESCRIBED_CLASS = 'described_class'
MSG = 'Use `%<replacement>s` instead of `%<src>s`.'
# @!method common_instance_exec_closure?(node)
- def_node_matcher :common_instance_exec_closure?, <<-PATTERN
+ def_node_matcher :common_instance_exec_closure?, <<~PATTERN
(block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
PATTERN
# @!method rspec_block?(node)
def_node_matcher :rspec_block?,
@@ -73,11 +73,11 @@
# @!method scope_changing_syntax?(node)
def_node_matcher :scope_changing_syntax?, '{def class module}'
# @!method described_constant(node)
- def_node_matcher :described_constant, <<-PATTERN
+ def_node_matcher :described_constant, <<~PATTERN
(block (send _ :describe $(const ...) ...) (args) $_)
PATTERN
# @!method contains_described_class?(node)
def_node_search :contains_described_class?,
@@ -146,18 +146,18 @@
node.send_type? && node.method?(:described_class)
end
end
def offensive_described_class?(node)
- return unless node.const_type?
+ return false unless node.const_type?
# E.g. `described_class::CONSTANT`
- return if contains_described_class?(node)
+ return false if contains_described_class?(node)
nearest_described_class, = node.each_ancestor(:block)
.map { |ancestor| described_constant(ancestor) }.find(&:itself)
- return if nearest_described_class.equal?(node)
+ return false if nearest_described_class.equal?(node)
full_const_name(nearest_described_class) == full_const_name(node)
end
def full_const_name(node)