module RuboCop::Cop::StringLiteralsHelp
Common functionality for cops checking single/double quotes.
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/mixin/string_literals_help.rb, line 19 def autocorrect(node) return if node.dstr_type? lambda do |corrector| str = node.str_content if style == :single_quotes corrector.replace(node.source_range, to_string_literal(str)) else corrector.replace(node.source_range, str.inspect) end end end
wrong_quotes?(node)
click to toggle source
# File lib/rubocop/cop/mixin/string_literals_help.rb, line 9 def wrong_quotes?(node) src = node.source return false if src.start_with?('%', '?') if style == :single_quotes src !~ /'/ && !double_quotes_acceptable?(node.str_content) else src !~ /" | \ | \#/x end end