Sha256: 9ca8c07d754f2e42c521be2b59db7e2f3065e857e5e8694e806ed49b57855cc1

Contents?: true

Size: 774 Bytes

Versions: 7

Compression:

Stored size: 774 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # Handles adding and checking ignored nodes.
    module IgnoredNode
      def ignore_node(node)
        @ignored_nodes ||= []
        @ignored_nodes << node
      end

      def part_of_ignored_node?(node)
        return false unless @ignored_nodes
        expression = node.loc.expression
        @ignored_nodes.each do |ignored_node|
          if ignored_node.loc.expression.begin_pos <= expression.begin_pos &&
            ignored_node.loc.expression.end_pos >= expression.end_pos
            return true
          end
        end

        false
      end

      def ignored_node?(node)
        # Same object found in array?
        @ignored_nodes && @ignored_nodes.any? { |n| n.eql?(node) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-0.20.1 lib/rubocop/cop/ignored_node.rb
rubocop-0.20.0 lib/rubocop/cop/ignored_node.rb
rubocop-0.19.1 lib/rubocop/cop/ignored_node.rb
rubocop-0.19.0 lib/rubocop/cop/ignored_node.rb
rubocop-0.18.1 lib/rubocop/cop/ignored_node.rb
rubocop-0.18.0 lib/rubocop/cop/ignored_node.rb
rubocop-0.17.0 lib/rubocop/cop/ignored_node.rb