diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-03 13:11:13 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-05 12:41:04 -0700 |
commit | 9802d7c075c8b7dae42dbcecd92d492f7fa128ac (patch) | |
tree | 0d13de92dc631081f9bcdaddedd6294051e3423b /lib/chef/mixin | |
parent | 4978a9a8a402477f3b35f43404701d6a5cf26fa1 (diff) | |
download | chef-9802d7c075c8b7dae42dbcecd92d492f7fa128ac.tar.gz |
Style/NegatedIf
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/params_validate.rb | 10 | ||||
-rw-r--r-- | lib/chef/mixin/properties.rb | 12 | ||||
-rw-r--r-- | lib/chef/mixin/securable.rb | 2 | ||||
-rw-r--r-- | lib/chef/mixin/user_context.rb | 2 | ||||
-rw-r--r-- | lib/chef/mixin/windows_architecture_helper.rb | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb index eafe50382b..cb6a99d4f3 100644 --- a/lib/chef/mixin/params_validate.rb +++ b/lib/chef/mixin/params_validate.rb @@ -237,7 +237,7 @@ class Chef # def _pv_cannot_be(opts, key, predicate_method_base_name) value = _pv_opts_lookup(opts, key) - if !value.nil? + unless value.nil? Array(predicate_method_base_name).each do |method_name| predicate_method = :"#{method_name}?" @@ -279,7 +279,7 @@ class Chef def _pv_default(opts, key, default_value) value = _pv_opts_lookup(opts, key) if value.nil? - default_value = default_value.freeze if !default_value.is_a?(DelayedEvaluator) + default_value = default_value.freeze unless default_value.is_a?(DelayedEvaluator) opts[key] = default_value end end @@ -299,7 +299,7 @@ class Chef # def _pv_regex(opts, key, regex) value = _pv_opts_lookup(opts, key) - if !value.nil? + unless value.nil? Array(regex).flatten.each do |r| return true if r.match(value.to_s) end @@ -323,7 +323,7 @@ class Chef raise ArgumentError, "Callback list must be a hash!" unless callbacks.kind_of?(Hash) value = _pv_opts_lookup(opts, key) - if !value.nil? + unless value.nil? callbacks.each do |message, zeproc| unless zeproc.call(value) raise Exceptions::ValidationFailed, _validation_message(key, "Option #{key}'s value #{value} #{message}!") @@ -486,7 +486,7 @@ class Chef def get(resource, nil_set: false) value = super # All values are sticky, frozen or not - if !is_set?(resource) + unless is_set?(resource) set_value(resource, value) end value diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb index faf047885c..dcae012a23 100644 --- a/lib/chef/mixin/properties.rb +++ b/lib/chef/mixin/properties.rb @@ -102,7 +102,7 @@ class Chef options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo } - options[:instance_variable_name] = :"@#{name}" if !options.key?(:instance_variable_name) + options[:instance_variable_name] = :"@#{name}" unless options.key?(:instance_variable_name) options[:name] = name options[:declared_in] = self @@ -191,7 +191,7 @@ class Chef # @return [Array<Property>] All properties in desired state. # def state_properties(*names) - if !names.empty? + unless names.empty? names = names.map { |name| name.to_sym }.uniq local_properties = properties(false) @@ -240,7 +240,7 @@ class Chef # @return [Array<Property>] All identity properties. # def identity_properties(*names) - if !names.empty? + unless names.empty? names = names.map { |name| name.to_sym } # Add or change properties that are not part of the identity. @@ -288,7 +288,7 @@ class Chef # def property_is_set?(name) property = self.class.properties[name.to_sym] - raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property + raise ArgumentError, "Property #{name} is not defined in class #{self}" unless property property.is_set?(self) end @@ -302,7 +302,7 @@ class Chef # def reset_property(name) property = self.class.properties[name.to_sym] - raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property + raise ArgumentError, "Property #{name} is not defined in class #{self}" unless property property.reset(self) end @@ -314,7 +314,7 @@ class Chef # @return [String] The description of the property. def property_description(name) property = self.class.properties[name.to_sym] - raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property + raise ArgumentError, "Property #{name} is not defined in class #{self}" unless property property.description end diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index 9da8ae4c2f..92e07e4e0f 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -134,7 +134,7 @@ class Chef end [ principals ].flatten.each do |principal| - if !principal.is_a?(String) + unless principal.is_a?(String) raise ArgumentError, "principals parameter must be a string or array of strings representing usernames" end end diff --git a/lib/chef/mixin/user_context.rb b/lib/chef/mixin/user_context.rb index c49bdc7880..bd73e818b0 100644 --- a/lib/chef/mixin/user_context.rb +++ b/lib/chef/mixin/user_context.rb @@ -30,7 +30,7 @@ class Chef raise Exceptions::UnsupportedPlatform, "User context impersonation is supported only on the Windows platform" end - if ! block_given? + unless block_given? raise ArgumentError, "You must supply a block to `with_user_context`" end diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb index ec7f675825..cf05a682b5 100644 --- a/lib/chef/mixin/windows_architecture_helper.rb +++ b/lib/chef/mixin/windows_architecture_helper.rb @@ -82,7 +82,7 @@ class Chef end def assert_valid_windows_architecture!(architecture) - if !valid_windows_architecture?(architecture) + unless valid_windows_architecture?(architecture) raise Chef::Exceptions::Win32ArchitectureIncorrect, "The specified architecture was not valid. It must be one of :i386 or :x86_64" end |