Module: RuboCop::Cop::MethodPreference
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/rubocop/cop/mixin/method_preference.rb |
Overview
Common code for cops that deal with preferred methods.
Instance Method Summary
- #default_cop_config private
- #preferred_method(method) private
- #preferred_methods private
Instance Method Details
#default_cop_config (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/method_preference.rb', line 25
def default_cop_config ConfigLoader.default_configuration[cop_name] end
#preferred_method(method) (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/method_preference.rb', line 9
def preferred_method(method) preferred_methods[method.to_sym] end
#preferred_methods (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/method_preference.rb', line 13
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) }.transform_keys(&:to_sym) end end