class RuboCop::Cop::Lint::InterpolationCheck

This cop checks for interpolation in a single quoted string.

@example

# bad

foo = 'something with #{interpolation} inside'

@example

# good

foo = "something with #{interpolation} inside"

Constants

MSG

Public Instance Methods

heredoc?(node) click to toggle source
# File lib/rubocop/cop/lint/interpolation_check.rb, line 30
def heredoc?(node)
  node.loc.is_a?(Parser::Source::Map::Heredoc) ||
    (node.parent && heredoc?(node.parent))
end
on_str(node) click to toggle source
# File lib/rubocop/cop/lint/interpolation_check.rb, line 23
def on_str(node)
  return if heredoc?(node)
  return if node.parent && node.parent.dstr_type?
  return unless node.str_content.scrub =~ /#\{.*\}/
  add_offense(node)
end