Sha256: c5b15e0ace4e23815acc08b4c65e69de8313d72364650d124aaa21032d84ed0c

Contents?: true

Size: 876 Bytes

Versions: 14

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module Style
      # Checks if uses of quotes match the configured preference.
      class StringLiterals < Cop
        include ConfigurableEnforcedStyle
        include StringLiteralsHelp

        private

        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)
          # If it's a string within an interpolation, then it's not an offense
          # for this cop.
          return false if inside_interpolation?(node)

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rubocop-0.35.1 lib/rubocop/cop/style/string_literals.rb
rubocop-0.35.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.34.2 lib/rubocop/cop/style/string_literals.rb
rubocop-0.34.1 lib/rubocop/cop/style/string_literals.rb
rubocop-0.34.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.33.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.32.1 lib/rubocop/cop/style/string_literals.rb
rubocop-0.32.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.31.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.30.1 lib/rubocop/cop/style/string_literals.rb
rubocop-0.30.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.29.1 lib/rubocop/cop/style/string_literals.rb
rubocop-0.29.0 lib/rubocop/cop/style/string_literals.rb
rubocop-0.28.0 lib/rubocop/cop/style/string_literals.rb