Sha256: b612e884f5d446baeb505c05781a0686db7792297a5059fe471bf45d37611315

Contents?: true

Size: 898 Bytes

Versions: 6904

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common code for cops that deal with preferred methods.
    module MethodPreference
      private

      def preferred_method(method)
        preferred_methods[method.to_sym]
      end

      def preferred_methods
        @preferred_methods ||=
          begin
            # Make sure default configuration 'foo' => 'bar' is removed from
            # the total configuration if there is a 'bar' => 'foo' override.
            default = default_cop_config['PreferredMethods']
            merged = cop_config['PreferredMethods']
            overrides = merged.values - default.values
            merged.reject { |key, _| overrides.include?(key) }
                  .map { |k, v| [k.to_sym, v] }.to_h
          end
      end

      def default_cop_config
        ConfigLoader.default_configuration[cop_name]
      end
    end
  end
end

Version data entries

6,904 entries across 6,880 versions & 29 rubygems

Version Path
rubocop-0.86.0 lib/rubocop/cop/mixin/method_preference.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/mixin/method_preference.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/mixin/method_preference.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.85.1 lib/rubocop/cop/mixin/method_preference.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.85.0 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.84.0 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.83.0 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.82.0 lib/rubocop/cop/mixin/method_preference.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/mixin/method_preference.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.81.0 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.80.1 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.80.0 lib/rubocop/cop/mixin/method_preference.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/mixin/method_preference.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.79.0 lib/rubocop/cop/mixin/method_preference.rb
rubocop-0.78.0 lib/rubocop/cop/mixin/method_preference.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.77.0/lib/rubocop/cop/mixin/method_preference.rb