Sha256: fdd3b93fbea456b78b4d3443c211c02619c6d6641c1034d044090d5a2b60af25

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This module encapsulates the ability to allow certain methods when
    # parsing.
    module AllowedMethods
      private

      # @api public
      def allowed_method?(name)
        allowed_methods.include?(name.to_s)
      end

      # @deprecated Use allowed_method? instead
      alias ignored_method? allowed_method?

      # @api public
      def allowed_methods
        if cop_config_deprecated_values.any?(Regexp)
          cop_config_allowed_methods
        else
          cop_config_allowed_methods + cop_config_deprecated_values
        end
      end

      def cop_config_allowed_methods
        @cop_config_allowed_methods ||= Array(cop_config.fetch('AllowedMethods', []))
      end

      def cop_config_deprecated_values
        @cop_config_deprecated_values ||=
          Array(cop_config.fetch('IgnoredMethods', [])) +
          Array(cop_config.fetch('ExcludedMethods', []))
      end
    end
    # @deprecated IgnoredMethods class has been replaced with AllowedMethods.
    IgnoredMethods = AllowedMethods
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/mixin/allowed_methods.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.44.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.44.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.43.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.42.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.41.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.41.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.40.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.39.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.38.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.37.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.37.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.36.0 lib/rubocop/cop/mixin/allowed_methods.rb