diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 14:55:20 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 15:08:43 -0700 |
commit | 21189d25a9385aa9ff3368716824b8333475a08b (patch) | |
tree | d4316d70ff88b5a43ffff90d04bd789da51cf9d4 /lib/chef/mixin | |
parent | fb6c052ae6d58db2499cf04ef0595d1e06a4c13c (diff) | |
download | chef-21189d25a9385aa9ff3368716824b8333475a08b.tar.gz |
fix Style/PreferredHashMethods
absolutely hard requirement on the fixes that went into chef-config 2.2.11, so the
floor of that gem is bumped up.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/deep_merge.rb | 2 | ||||
-rw-r--r-- | lib/chef/mixin/params_validate.rb | 18 | ||||
-rw-r--r-- | lib/chef/mixin/properties.rb | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb index 9ec2b397d4..1ecd00eb2d 100644 --- a/lib/chef/mixin/deep_merge.rb +++ b/lib/chef/mixin/deep_merge.rb @@ -106,7 +106,7 @@ class Chef if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash) merge_with.each do |key, merge_with_value| value = - if merge_onto.has_key?(key) + if merge_onto.key?(key) hash_only_merge(merge_onto[key], merge_with_value) else merge_with_value diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb index 4ed4b3ab3b..f77adecd60 100644 --- a/lib/chef/mixin/params_validate.rb +++ b/lib/chef/mixin/params_validate.rb @@ -106,7 +106,7 @@ class Chef when false true when Hash - @validation_message[key] = validation.delete(:validation_message) if validation.has_key?(:validation_message) + @validation_message[key] = validation.delete(:validation_message) if validation.key?(:validation_message) validation.each do |check, carg| check_method = "_pv_#{check}" if respond_to?(check_method, true) @@ -132,14 +132,14 @@ class Chef private def _validation_message(key, default) - @validation_message.has_key?(key) ? @validation_message[key] : default + @validation_message.key?(key) ? @validation_message[key] : default end # Return the value of a parameter, or nil if it doesn't exist. def _pv_opts_lookup(opts, key) - if opts.has_key?(key.to_s) + if opts.key?(key.to_s) opts[key.to_s] - elsif opts.has_key?(key.to_sym) + elsif opts.key?(key.to_sym) opts[key.to_sym] else nil @@ -149,8 +149,8 @@ class Chef # Raise an exception if the parameter is not found. def _pv_required(opts, key, is_required = true, explicitly_allows_nil = false) if is_required - return true if opts.has_key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?) - return true if opts.has_key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?) + return true if opts.key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?) + return true if opts.key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?) raise Exceptions::ValidationFailed, _validation_message(key, "Required argument #{key.inspect} is missing!") end true @@ -404,7 +404,7 @@ class Chef # ``` # def _pv_is(opts, key, to_be) - return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym) + return true if !opts.key?(key.to_s) && !opts.key?(key.to_sym) value = _pv_opts_lookup(opts, key) to_be = [ to_be ].flatten(1) errors = [] @@ -454,10 +454,10 @@ class Chef # ``` # def _pv_coerce(opts, key, coercer) - if opts.has_key?(key.to_s) + if opts.key?(key.to_s) raise Exceptions::CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate opts[key.to_s] = instance_exec(opts[key], &coercer) - elsif opts.has_key?(key.to_sym) + elsif opts.key?(key.to_sym) raise Exceptions::CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate opts[key.to_sym] = instance_exec(opts[key], &coercer) end diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb index fb765fbb3a..f72a22db2d 100644 --- a/lib/chef/mixin/properties.rb +++ b/lib/chef/mixin/properties.rb @@ -102,14 +102,14 @@ class Chef options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo } - options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name) + options[:instance_variable_name] = :"@#{name}" if !options.key?(:instance_variable_name) options[:name] = name options[:declared_in] = self if type == NOT_PASSED # If a type is not passed, the property derives from the # superclass property (if any) - if properties.has_key?(name) + if properties.key?(name) property = properties[name].derive(**options) else property = property_type(**options) |