class RuboCop::Cop::Style::RedundantHeredocDelimiterQuotes


EOS
newlines
Preserve <br>do_something(<<~‘EOS’)
EOS
#{string_interpolation_style_text_not_evaluated}
do_something(<<~‘EOS’)
EOS
no string interpolation style text
do_something(<<~EOS)
# good
EOS
no string interpolation style text
do_something(<<~‘EOS’)
# bad
@example
Checks for redundant heredoc delimiter quotes.

def need_heredoc_delimiter_quotes?(node)

def need_heredoc_delimiter_quotes?(node)
  heredoc_delimiter = node.source.delete(heredoc_type(node))
  return true unless heredoc_delimiter.start_with?("'", '"')
  node.loc.heredoc_end.source.strip.match?(/\W/) ||
    node.loc.heredoc_body.source.match?(STRING_INTERPOLATION_OR_ESCAPED_CHARACTER_PATTERN)
end

def on_heredoc(node)

def on_heredoc(node)
  return if need_heredoc_delimiter_quotes?(node)
  replacement = "#{heredoc_type(node)}#{delimiter_string(node)}"
  add_offense(node, message: format(MSG, replacement: replacement)) do |corrector|
    corrector.replace(node, replacement)
  end
end