Skip to content

Commit

Permalink
Simplify heredoc detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Jan 10, 2019
1 parent 2f5f125 commit 9c0fd1b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/rubocop/cop/rspec/aggregate_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,9 @@ def example_method?(method_name)
# Searches for HEREDOC in examples. It can be tricky to aggregate,
# especially when interleaved with parenthesis or curly braces.
def contains_heredoc?(node)
return unless node.is_a? AST::Node
return true if (node.dstr_type? || node.str_type?) && node.heredoc?
return true if node.respond_to?(:heredoc) && node.heredoc?

node.children.compact.any? { |child| contains_heredoc?(child) }
node.each_child_node.any? { |child| contains_heredoc?(child) }
end

def_node_matcher :subject_with_no_args?, <<-PATTERN
Expand Down

0 comments on commit 9c0fd1b

Please sign in to comment.