class RuboCop::Cop::Style::StringLiterals

Checks if uses of quotes match the configured preference.

def message(*)

def message(*)
  if style == :single_quotes
    "Prefer single-quoted strings when you don't need string " \
    'interpolation or special symbols.'
  else
    'Prefer double-quoted strings unless you need single quotes to ' \
    'avoid extra backslashes for escaping.'
  end
end

def offense?(node)

def offense?(node)
  wrong_quotes?(node, style)
end

def on_dstr(node)

def on_dstr(node)
  # A dstr node with dstr and str children is a concatenated
  # string. Don't ignore the whole thing.
  return if node.children.find { |child| child.type == :str }
  # Dynamic strings can not use single quotes, and quotes inside
  # interpolation expressions are checked by the
  # StringLiteralsInInterpolation cop, so ignore.
  ignore_node(node)
end