class RuboCop::Cop::Lint::InterpolationCheck
foo = “something with #{interpolation} inside”
# good
@example
foo = ‘something with #{interpolation} inside’
# bad
@example
This cop checks for interpolation in a single quoted string.
def heredoc?(node)
def heredoc?(node) node.loc.is_a?(Parser::Source::Map::Heredoc) || (node.parent && heredoc?(node.parent)) end
def on_str(node)
def on_str(node) return if heredoc?(node) parent = node.parent return if parent && (parent.dstr_type? || parent.regexp_type?) return unless node.source.scrub =~ /(?<!\\)#\{.*\}/ add_offense(node) end