Sha256: 4e59e5e2f500a7d30b626b032c2f5c6d52af6742b66f9d22cc8b2ed688fcd67b

Contents?: true

Size: 1.25 KB

Versions: 149

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This module encapsulates the ability to allow certain methods when
    # parsing. Even if the code is in offense, if it contains methods
    # that are allowed. This module is equivalent to the IgnoredMethods module,
    # which will be deprecated in RuboCop 2.0.
    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

149 entries across 148 versions & 17 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/mixin/allowed_methods.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/mixin/allowed_methods.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.64.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.63.4 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.63.3 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.63.2 lib/rubocop/cop/mixin/allowed_methods.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.63.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.63.0 lib/rubocop/cop/mixin/allowed_methods.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.62.1 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.62.0 lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.61.0 lib/rubocop/cop/mixin/allowed_methods.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.2/lib/rubocop/cop/mixin/allowed_methods.rb
rubocop-1.60.2 lib/rubocop/cop/mixin/allowed_methods.rb
study_line-0.2.7 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cop/mixin/allowed_methods.rb
study_line-0.2.6 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cop/mixin/allowed_methods.rb
study_line-0.2.5 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cop/mixin/allowed_methods.rb
study_line-0.2.4 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cop/mixin/allowed_methods.rb