Module: Rubocop::Cop::Style::StringHelp

Included in:
CharacterLiteral, StringLiterals
Defined in:
lib/rubocop/cop/style/string_help.rb

Overview

Checks for uses of double quotes where single quotes would do.

Instance Method Summary collapse

Instance Method Details

#on_dstr(node) ⇒ Object



17
18
19
# File 'lib/rubocop/cop/style/string_help.rb', line 17

def on_dstr(node)
  ignore_node(node)
end

#on_regexp(node) ⇒ Object



21
22
23
# File 'lib/rubocop/cop/style/string_help.rb', line 21

def on_regexp(node)
  ignore_node(node)
end

#on_str(node) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/rubocop/cop/style/string_help.rb', line 8

def on_str(node)
  # Constants like __FILE__ are handled as strings,
  # but don't respond to begin.
  return unless node.loc.respond_to?(:begin) && node.loc.begin
  return if part_of_ignored_node?(node)

  convention(node, :expression) if offence?(node)
end