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

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

Overview

Classes that include this module just implement functions to determine what is an offence and how to do auto-correction. They get help with adding offences for the faulty string nodes, and with filtering out nodes.

Instance Method Summary collapse

Instance Method Details

#on_dstr(node) ⇒ Object



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

def on_dstr(node)
  ignore_node(node)
end

#on_regexp(node) ⇒ Object



24
25
26
# File 'lib/rubocop/cop/style/string_help.rb', line 24

def on_regexp(node)
  ignore_node(node)
end

#on_str(node) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rubocop/cop/style/string_help.rb', line 11

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