Sha256: 14a402431d1636e2d9471b43ff76882bfc851c61e2f22c25ccb8d11e120c96c3

Contents?: true

Size: 679 Bytes

Versions: 7

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This module encapsulates the ability to ignore certain lines when
    # parsing.
    module IgnoredPattern
      def ignored_line?(line)
        line = if line.respond_to?(:source_line)
                 line.source_line
               elsif line.respond_to?(:node)
                 line.node.source_range.source_line
               end

        matches_ignored_pattern?(line)
      end

      def matches_ignored_pattern?(line)
        ignored_patterns.any? { |pattern| Regexp.new(pattern).match(line) }
      end

      def ignored_patterns
        cop_config['IgnoredPatterns'] || []
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-0.52.0 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.51.0 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.50.0 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.49.1 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.49.0 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.48.1 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-0.48.0 lib/rubocop/cop/mixin/ignored_pattern.rb