Sha256: 84a49f47059fb942e30a1470d0b8a04c93e317c6ec1151eef18b686d5c19e0c7

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # Classes that include this module just implement functions to determine
    # what is an offense and how to do auto-correction. They get help with
    # adding offenses for the faulty string nodes, and with filtering out
    # nodes.
    module StringHelp
      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)

        if offense?(node)
          add_offense(node, :expression) { opposite_style_detected }
        else
          correct_style_detected
        end
      end

      def on_dstr(node)
        ignore_node(node)
      end

      def on_regexp(node)
        ignore_node(node)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.20.1 lib/rubocop/cop/mixin/string_help.rb
rubocop-0.20.0 lib/rubocop/cop/mixin/string_help.rb
rubocop-0.19.1 lib/rubocop/cop/mixin/string_help.rb
rubocop-0.19.0 lib/rubocop/cop/mixin/string_help.rb