Module: RuboCop::Chef::AutocorrectHelpers

Overview

Helpers for use in autocorrection

Instance Method Summary collapse

Instance Method Details

#expression_including_heredocs(node) ⇒ Object

if the node has a heredoc as an argument you’ll only get the start of the heredoc and removing the node will result in broken ruby. This way we match the node and the entire heredoc for removal



24
25
26
27
28
29
30
# File 'lib/rubocop/chef/autocorrect_helpers.rb', line 24

def expression_including_heredocs(node)
  if node.arguments.last.respond_to?(:heredoc?) && node.arguments.last.heredoc?
    node.loc.expression.join(node.arguments.last.loc.heredoc_end)
  else
    node.loc.expression
  end
end