Sha256: 976fba9e0185b199a331d239db1865b10a910db72e52cfbeba6267809cc8d694

Contents?: true

Size: 695 Bytes

Versions: 81

Compression:

Stored size: 695 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This module encapsulates the ability to ignore certain lines when
    # parsing.
    module IgnoredPattern
      private

      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

81 entries across 81 versions & 10 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/mixin/ignored_pattern.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.27.0 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.26.1 lib/rubocop/cop/mixin/ignored_pattern.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/rubocop-1.26.0/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.26.0 lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.25.1 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.25.0 lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/rubocop-1.24.0/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.24.1 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.24.0 lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.23.0 lib/rubocop/cop/mixin/ignored_pattern.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.22.3 lib/rubocop/cop/mixin/ignored_pattern.rb
rubocop-1.22.2 lib/rubocop/cop/mixin/ignored_pattern.rb