class RuboCop::Cop::Style::RedundantStringEscape
def allowed_escape?(node, range)
def allowed_escape?(node, range) escaped = range.source[(1..-1)] # Inside a single-quoted string, escapes (except \\ and \') do not have special meaning, # and so are not redundant, as they are a literal backslash. return true if interpolation_not_enabled?(node) # Strictly speaking a few single-letter chars are currently unnecessary to "escape", e.g. # d, but enumerating them is rather difficult, and their behavior could change over time # with different versions of Ruby so that e.g. /\d/ != /d/ return true if /[\n\\[[:alnum:]]]/.match?(escaped[0]) return true if escaped[0] == ' ' && (percent_array_literal?(node) || node.heredoc?) return true if disabling_interpolation?(range) return true if delimiter?(node, escaped[0]) false end