summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-03 13:11:13 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-05 12:41:04 -0700
commit9802d7c075c8b7dae42dbcecd92d492f7fa128ac (patch)
tree0d13de92dc631081f9bcdaddedd6294051e3423b
parent4978a9a8a402477f3b35f43404701d6a5cf26fa1 (diff)
downloadchef-9802d7c075c8b7dae42dbcecd92d492f7fa128ac.tar.gz
Style/NegatedIf
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--chef-config/lib/chef-config/config.rb2
-rw-r--r--chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb2
-rw-r--r--chef-config/spec/unit/config_spec.rb2
-rw-r--r--lib/chef/api_client/registration.rb2
-rw-r--r--lib/chef/application/apply.rb2
-rw-r--r--lib/chef/application/client.rb2
-rw-r--r--lib/chef/application/solo.rb2
-rw-r--r--lib/chef/application/windows_service_manager.rb2
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb8
-rw-r--r--lib/chef/chef_fs/command_line.rb2
-rw-r--r--lib/chef/chef_fs/config.rb2
-rw-r--r--lib/chef/chef_fs/file_pattern.rb12
-rw-r--r--lib/chef/chef_fs/file_system.rb4
-rw-r--r--lib/chef/chef_fs/file_system/base_fs_object.rb12
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/environments_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/memory/memory_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/directory.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item.rb4
-rw-r--r--lib/chef/event_dispatch/dispatcher.rb2
-rw-r--r--lib/chef/file_access_control/windows.rb6
-rw-r--r--lib/chef/formatters/doc.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb2
-rw-r--r--lib/chef/formatters/indentable_output_stream.rb2
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb2
-rw-r--r--lib/chef/http/json_to_model_output.rb2
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--lib/chef/knife/cookbook_upload.rb2
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb2
-rw-r--r--lib/chef/knife/core/ui.rb2
-rw-r--r--lib/chef/knife/deps.rb8
-rw-r--r--lib/chef/knife/edit.rb4
-rw-r--r--lib/chef/knife/ssh.rb4
-rw-r--r--lib/chef/knife/supermarket_share.rb2
-rw-r--r--lib/chef/mixin/params_validate.rb10
-rw-r--r--lib/chef/mixin/properties.rb12
-rw-r--r--lib/chef/mixin/securable.rb2
-rw-r--r--lib/chef/mixin/user_context.rb2
-rw-r--r--lib/chef/mixin/windows_architecture_helper.rb2
-rw-r--r--lib/chef/node/common_api.rb4
-rw-r--r--lib/chef/node_map.rb6
-rw-r--r--lib/chef/property.rb4
-rw-r--r--lib/chef/provider.rb2
-rw-r--r--lib/chef/provider/apt_update.rb2
-rw-r--r--lib/chef/provider/dsc_resource.rb2
-rw-r--r--lib/chef/provider/dsc_script.rb2
-rw-r--r--lib/chef/provider/file.rb4
-rw-r--r--lib/chef/provider/mount/aix.rb4
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--lib/chef/provider/remote_file/fetcher.rb2
-rw-r--r--lib/chef/provider/service/openbsd.rb10
-rw-r--r--lib/chef/provider/service/upstart.rb2
-rw-r--r--lib/chef/provider/windows_script.rb2
-rw-r--r--lib/chef/resource.rb6
-rw-r--r--lib/chef/resource/dnf_package.rb2
-rw-r--r--lib/chef/resource/dsc_resource.rb2
-rw-r--r--lib/chef/resource/file.rb2
-rw-r--r--lib/chef/resource/resource_notification.rb4
-rw-r--r--lib/chef/resource/windows_script.rb2
-rw-r--r--lib/chef/role.rb4
-rw-r--r--lib/chef/run_context.rb4
-rw-r--r--lib/chef/util/dsc/configuration_generator.rb2
-rw-r--r--lib/chef/util/powershell/cmdlet.rb2
-rw-r--r--lib/chef/util/windows/logon_session.rb10
-rw-r--r--lib/chef/win32/eventlog.rb2
-rw-r--r--lib/chef/win32/memory.rb2
-rw-r--r--lib/chef/win32/registry.rb2
-rw-r--r--lib/chef/win32/security/security_descriptor.rb4
-rw-r--r--spec/functional/resource/group_spec.rb4
-rw-r--r--spec/functional/run_lock_spec.rb4
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb2
-rw-r--r--spec/support/platforms/win32/spec_service.rb2
-rw-r--r--spec/support/shared/integration/knife_support.rb8
-rw-r--r--spec/support/shared/unit/file_system_support.rb2
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb2
-rw-r--r--spec/unit/provider/powershell_script_spec.rb2
-rw-r--r--spec/unit/provider_resolver_spec.rb4
87 files changed, 149 insertions, 149 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 2348f0677f..88ce6216c4 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -1073,7 +1073,7 @@ module ChefConfig
# Check if the proxy string contains a scheme. If not, add the url's scheme to the
# proxy before parsing. The regex /^.*:\/\// matches, for example, http://. Reusing proxy
# here since we are really just trying to get the string built correctly.
- proxy = if !proxy_env_var.empty?
+ proxy = unless proxy_env_var.empty?
if proxy_env_var =~ /^.*:\/\//
URI.parse(proxy_env_var)
else
diff --git a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
index ca1bdb4c0b..b7a8a178ea 100644
--- a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
+++ b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
@@ -32,7 +32,7 @@ module ChefConfig
def fuzzy_hostname_match?(hostname, match)
# Do greedy matching by adding wildcard if it is not specified
- match = "*" + match if !match.start_with?("*")
+ match = "*" + match unless match.start_with?("*")
Fuzzyurl.matches?(Fuzzyurl.mask(hostname: match), hostname)
end
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 378cc4a4a1..ed52c5606e 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -618,7 +618,7 @@ RSpec.describe ChefConfig::Config do
# On Windows, we'll detect an omnibus build and set this to the
# cacert.pem included in the package, but it's nil if you're on Windows
# w/o omnibus (e.g., doing development on Windows, custom build, etc.)
- if !is_windows
+ unless is_windows
it "ChefConfig::Config[:ssl_ca_file] defaults to nil" do
expect(ChefConfig::Config[:ssl_ca_file]).to be_nil
end
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb
index 07ecd9a2a5..270945cfc2 100644
--- a/lib/chef/api_client/registration.rb
+++ b/lib/chef/api_client/registration.rb
@@ -72,7 +72,7 @@ class Chef
def assert_destination_writable!
abs_path = File.expand_path(destination)
- if !File.exists?(File.dirname(abs_path))
+ unless File.exists?(File.dirname(abs_path))
begin
FileUtils.mkdir_p(File.dirname(abs_path))
rescue Errno::EACCES
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 1a9b115632..a5fe2260db 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -184,7 +184,7 @@ class Chef::Application::Apply < Chef::Application
@recipe_text = STDIN.read
temp_recipe_file
else
- if !ARGV[0]
+ unless ARGV[0]
puts opt_parser
Chef::Application.exit! "No recipe file provided", Chef::Exceptions::RecipeNotFound.new
end
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index d3e9a77646..1e1b76de15 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -469,7 +469,7 @@ class Chef::Application::Client < Chef::Application
loop do
sleep_then_run_chef_client(time_to_sleep)
- Chef::Application.exit!("Exiting", 0) if !Chef::Config[:interval]
+ Chef::Application.exit!("Exiting", 0) unless Chef::Config[:interval]
end
end
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 29ee56a7e4..0da696c05c 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -342,7 +342,7 @@ class Chef::Application::Solo < Chef::Application
end
run_chef_client
- if !Chef::Config[:interval]
+ unless Chef::Config[:interval]
Chef::Application.exit! "Exiting", 0
end
rescue SystemExit => e
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 655cc3fe96..ace8d9d90a 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -81,7 +81,7 @@ class Chef
required_options = %i{service_name service_display_name service_description service_file_path}
required_options.each do |req_option|
- if !service_options.key?(req_option)
+ unless service_options.key?(req_option)
raise ArgumentError, "Service definition doesn't contain required option #{req_option}"
end
end
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index b74f76cab3..d8bb3bb7ed 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -246,7 +246,7 @@ class Chef
end
else
- if !data.is_a?(String)
+ unless data.is_a?(String)
raise "set only works with strings"
end
@@ -362,7 +362,7 @@ class Chef
if use_memory_store?(path)
@memory_store.set(path, data, *options)
else
- if !data.is_a?(String)
+ unless data.is_a?(String)
raise "set only works with strings: #{path} = #{data.inspect}"
end
@@ -466,7 +466,7 @@ class Chef
FileSystemCache.instance.delete!(policy.file_path)
found_policy = true
end
- raise ChefZero::DataStore::DataNotFoundError.new(path) if !found_policy
+ raise ChefZero::DataStore::DataNotFoundError.new(path) unless found_policy
end
else
@@ -645,7 +645,7 @@ class Chef
# Create the .uploaded-cookbook-version.json
cookbooks = chef_fs.child(cookbook_type)
- if !cookbooks.exists?
+ unless cookbooks.exists?
cookbooks = chef_fs.create_child(cookbook_type)
end
# We are calling a cookbooks-specific API, so get multiplexed_dirs out of the way if it is there
diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb
index 217fb208d3..265b95e22d 100644
--- a/lib/chef/chef_fs/command_line.rb
+++ b/lib/chef/chef_fs/command_line.rb
@@ -132,7 +132,7 @@ class Chef
end
end
end
- if !found_match
+ unless found_match
ui.error "#{pattern}: No such file or directory on remote or local" if ui
error = true
end
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 7940dbf1fe..48ebe75e27 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -150,7 +150,7 @@ class Chef
hosted_everything or allow repo_mode to default}
end
# Default to getting *everything* from the server.
- if !@chef_config[:repo_mode]
+ unless @chef_config[:repo_mode]
if is_hosted?
@chef_config[:repo_mode] = "hosted_everything"
else
diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb
index 5e3e276541..48e28ccc39 100644
--- a/lib/chef/chef_fs/file_pattern.rb
+++ b/lib/chef/chef_fs/file_pattern.rb
@@ -188,7 +188,7 @@ class Chef
end
def calculate
- if !@regexp
+ unless @regexp
@is_absolute = Chef::ChefFS::PathUtils.is_absolute?(@pattern)
full_regexp_parts = []
@@ -221,7 +221,7 @@ class Chef
full_regexp_parts.pop
normalized_parts.pop
- if !@has_double_star
+ unless @has_double_star
@regexp_parts.pop
@exact_parts.pop
end
@@ -232,7 +232,7 @@ class Chef
# Build up the regexp
full_regexp_parts << regexp
normalized_parts << part
- if !@has_double_star
+ unless @has_double_star
@regexp_parts << Regexp.new("^#{regexp}$")
@exact_parts << exact
end
@@ -265,7 +265,7 @@ class Chef
pattern.split(pattern_special_characters).each_with_index do |part, index|
# Odd indexes from the split are symbols. Even are normal bits.
if index.even?
- exact << part if !exact.nil?
+ exact << part unless exact.nil?
regexp << part
else
case part
@@ -283,7 +283,7 @@ class Chef
else
if part[0, 1] == '\\' && part.length == 2
# backslash escapes are only supported on Unix, and are handled here by leaving the escape on (it means the same thing in a regex)
- exact << part[1, 1] if !exact.nil?
+ exact << part[1, 1] unless exact.nil?
if regexp_escape_characters.include?(part[1, 1])
regexp << part
else
@@ -294,7 +294,7 @@ class Chef
exact = nil
regexp << part
else
- exact += part if !exact.nil?
+ exact += part unless exact.nil?
regexp << "\\#{part}"
end
end
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index dbf0704c9e..f1e7531de5 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -195,7 +195,7 @@ class Chef
# Check the outer regex pattern to see if it matches anything on the
# filesystem that isn't on the server
Chef::ChefFS::FileSystem.list(b_root, pattern).each do |b|
- if !found_paths.include?(b.display_path)
+ unless found_paths.include?(b.display_path)
a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.display_path)
yield [ a, b ]
end
@@ -229,7 +229,7 @@ class Chef
# Check b for children that aren't in a
b.children.each do |b_child|
- if !a_children_names.include?(b_child.bare_name)
+ unless a_children_names.include?(b_child.bare_name)
result << [ a.child(b_child.bare_name), b_child ]
end
end
diff --git a/lib/chef/chef_fs/file_system/base_fs_object.rb b/lib/chef/chef_fs/file_system/base_fs_object.rb
index e319232b0e..3d9eb5ae4d 100644
--- a/lib/chef/chef_fs/file_system/base_fs_object.rb
+++ b/lib/chef/chef_fs/file_system/base_fs_object.rb
@@ -108,14 +108,14 @@ class Chef
# Override children to report your *actual* list of children as an array.
def children
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
[]
end
# Expand this entry into a chef object (Chef::Role, ::Node, etc.)
def chef_object
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
nil
end
@@ -127,7 +127,7 @@ class Chef
# your entry class, and will be called without actually reading the
# file_contents. This is used for knife upload /cookbooks/cookbookname.
def create_child(name, file_contents)
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise OperationNotAllowedError.new(:create_child, self)
end
@@ -135,7 +135,7 @@ class Chef
# Delete this item, possibly recursively. Entries MUST NOT delete a
# directory unless recurse is true.
def delete(recurse)
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise OperationNotAllowedError.new(:delete, self)
end
@@ -171,14 +171,14 @@ class Chef
# Read the contents of this file entry.
def read
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise OperationNotAllowedError.new(:read, self)
end
# Write the contents of this file entry.
def write(file_contents)
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise OperationNotAllowedError.new(:write, self)
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
index 67b7e992b3..73f3d4f4e6 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
@@ -85,7 +85,7 @@ class Chef
parts[0, parts.length - 1].each do |part|
old_container = container
container = old_container.children.find { |child| part == child.name }
- if !container
+ unless container
container = CookbookSubdir.new(part, old_container, false, true)
old_container.add_child(container)
end
@@ -117,7 +117,7 @@ class Chef
end
end
else
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise MustDeleteRecursivelyError.new(self, "#{path_for_printing} must be deleted recursively")
end
@@ -133,7 +133,7 @@ class Chef
end
def compare_to(other)
- if !other.dir?
+ unless other.dir?
return [ !exists?, nil, nil ]
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb
index d1b415baf1..b21e13b256 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb
@@ -39,7 +39,7 @@ class Chef
def can_have_child?(name, is_dir)
if is_dir
- return false if !@recursive
+ return false unless @recursive
else
return false if @ruby_only && name !~ /\.rb$/
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
index dfacc7f5ec..21b7cdaff8 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
@@ -88,7 +88,7 @@ class Chef
# Work around the fact that CookbookUploader doesn't understand chef_repo_path (yet)
def with_actual_cookbooks_dir(actual_cookbook_path)
old_cookbook_path = Chef::Config.cookbook_path
- Chef::Config.cookbook_path = actual_cookbook_path if !Chef::Config.cookbook_path
+ Chef::Config.cookbook_path = actual_cookbook_path unless Chef::Config.cookbook_path
yield
ensure
diff --git a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
index 317fbb91cc..8970ad9b3e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
@@ -48,8 +48,8 @@ class Chef
end
def delete(recurse)
- if !recurse
- raise NotFoundError.new(self) if !exists?
+ unless recurse
+ raise NotFoundError.new(self) unless exists?
raise MustDeleteRecursivelyError.new(self, "#{path_for_printing} must be deleted recursively")
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb b/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb
index f213430d14..5425f8a2a5 100644
--- a/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb
@@ -40,13 +40,13 @@ class Chef
end
def delete(recurse)
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise DefaultEnvironmentCannotBeModifiedError.new(:delete, self)
end
def write(file_contents)
- raise NotFoundError.new(self) if !exists?
+ raise NotFoundError.new(self) unless exists?
raise DefaultEnvironmentCannotBeModifiedError.new(:write, self)
end
diff --git a/lib/chef/chef_fs/file_system/memory/memory_dir.rb b/lib/chef/chef_fs/file_system/memory/memory_dir.rb
index fdef10ff56..e52a4b7c0f 100644
--- a/lib/chef/chef_fs/file_system/memory/memory_dir.rb
+++ b/lib/chef/chef_fs/file_system/memory/memory_dir.rb
@@ -38,7 +38,7 @@ class Chef
dir = self
path_parts.each do |path_part|
subdir = dir.child(path_part)
- if !subdir.exists?
+ unless subdir.exists?
subdir = MemoryDir.new(path_part, dir)
dir.add_child(subdir)
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
index 2d8699621b..74170cc7a9 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
@@ -70,7 +70,7 @@ class Chef
# Write out .uploaded-cookbook-version.json
# cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path
- if !File.exists?(file_path)
+ unless File.exists?(file_path)
FileUtils.mkdir_p(file_path)
end
uploaded_cookbook_version_path = File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE)
@@ -83,7 +83,7 @@ class Chef
def chef_object
cb = cookbook_version
- if !cb
+ unless cb
Chef::Log.error("Cookbook #{file_path} empty.")
raise "Cookbook #{file_path} empty."
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
index a68277d567..31ccf1b24f 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
@@ -122,7 +122,7 @@ class Chef
FileSystemCache.instance.delete!(file_path)
begin
if dir?
- if !recurse
+ unless recurse
raise MustDeleteRecursivelyError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
index 6b5da9421c..2af4a9dd52 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
@@ -179,7 +179,7 @@ class Chef
#
def make_child_entry(name)
if CHILDREN.include?(name)
- return nil if !root_dir
+ return nil unless root_dir
return root_dir.child(name)
end
diff --git a/lib/chef/chef_fs/file_system/repository/directory.rb b/lib/chef/chef_fs/file_system/repository/directory.rb
index 1275cb4621..37a7081173 100644
--- a/lib/chef/chef_fs/file_system/repository/directory.rb
+++ b/lib/chef/chef_fs/file_system/repository/directory.rb
@@ -139,7 +139,7 @@ class Chef
def delete(recurse)
if exists?
- if !recurse
+ unless recurse
raise MustDeleteRecursivelyError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
index ed6a3d598c..6cb77a15a4 100644
--- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
@@ -109,7 +109,7 @@ class Chef
def delete(recurse)
if dir?
- if !recurse
+ unless recurse
raise MustDeleteRecursivelyError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 143b38aef8..1780b56239 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -198,7 +198,7 @@ class Chef
# If we exited early, perhaps due to any? finding a result, we want
# to make sure and throw away any extra results (gracefully) so that
# the next enumerator can start over.
- if !finished?
+ unless finished?
stop
end
raise
diff --git a/lib/chef/encrypted_data_bag_item.rb b/lib/chef/encrypted_data_bag_item.rb
index ff8512aec0..e8a979f7c0 100644
--- a/lib/chef/encrypted_data_bag_item.rb
+++ b/lib/chef/encrypted_data_bag_item.rb
@@ -130,7 +130,7 @@ class Chef::EncryptedDataBagItem
def self.load_secret(path = nil)
path ||= Chef::Config[:encrypted_data_bag_secret]
- if !path
+ unless path
raise ArgumentError, "No secret specified and no secret found at #{Chef::Config.platform_specific_path(Chef::Dist::CONF_DIR + '/encrypted_data_bag_secret')}"
end
@@ -145,7 +145,7 @@ class Chef::EncryptedDataBagItem
raise ArgumentError, "Remote key not found at '#{path}'"
end
else
- if !File.exist?(path)
+ unless File.exist?(path)
raise Errno::ENOENT, "file not found '#{path}'"
end
diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb
index 31e2afc8af..2fee4bcd0b 100644
--- a/lib/chef/event_dispatch/dispatcher.rb
+++ b/lib/chef/event_dispatch/dispatcher.rb
@@ -60,7 +60,7 @@ class Chef
@in_call = true
subscribers.each do |s|
# Skip new/unsupported event names
- next if !s.respond_to?(method_name)
+ next unless s.respond_to?(method_name)
mth = s.method(method_name)
# Trim arguments to match what the subscriber expects to allow
diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb
index ebf6f1f126..5090454fff 100644
--- a/lib/chef/file_access_control/windows.rb
+++ b/lib/chef/file_access_control/windows.rb
@@ -274,7 +274,7 @@ class Chef
acls = nil
- if !resource.deny_rights.nil?
+ unless resource.deny_rights.nil?
acls = [] if acls.nil?
resource.deny_rights.each do |rights|
@@ -287,7 +287,7 @@ class Chef
end
end
- if !resource.rights.nil?
+ unless resource.rights.nil?
acls = [] if acls.nil?
resource.rights.each do |rights|
@@ -300,7 +300,7 @@ class Chef
end
end
- if !resource.mode.nil?
+ unless resource.mode.nil?
acls = [] if acls.nil?
mode = (resource.mode.respond_to?(:oct) ? resource.mode.oct : resource.mode.to_i) & 0777
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index fa98c8ee37..f29e56094e 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -53,7 +53,7 @@ class Chef
def run_completed(node)
@end_time = Time.now
# Print out deprecations.
- if !deprecations.empty?
+ unless deprecations.empty?
puts_line ""
puts_line "Deprecated features used!"
deprecations.each do |message, details|
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 975bb39bd0..5141ed89fe 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -55,7 +55,7 @@ class Chef
if Chef::Platform.windows?
require_relative "../../win32/security"
- if !Chef::ReservedNames::Win32::Security.has_admin_privileges?
+ unless Chef::ReservedNames::Win32::Security.has_admin_privileges?
error_description.section("Missing Windows Admin Privileges", "#{Chef::Dist::CLIENT} doesn't have administrator privileges. This can be a possible reason for the resource failure.")
end
end
diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb
index 0481cb6217..f7e44be493 100644
--- a/lib/chef/formatters/indentable_output_stream.rb
+++ b/lib/chef/formatters/indentable_output_stream.rb
@@ -154,7 +154,7 @@ class Chef
end
def indent_line(options)
- if !@line_started
+ unless @line_started
# Print indents. If there is a stream name, either print it (if we're
# switching streams) or print enough blanks to match
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index 9b7c1517db..adab16f5bf 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -91,7 +91,7 @@ class Chef
raise ArgumentError, "Specified guard_interpreter resource #{parent_resource.guard_interpreter} unknown for this platform"
end
- if ! resource_class.ancestors.include?(Chef::Resource::Execute)
+ unless resource_class.ancestors.include?(Chef::Resource::Execute)
raise ArgumentError, "Specified guard interpreter class #{resource_class} must be a kind of Chef::Resource::Execute resource"
end
diff --git a/lib/chef/http/json_to_model_output.rb b/lib/chef/http/json_to_model_output.rb
index c908d0d23d..a1986bfce5 100644
--- a/lib/chef/http/json_to_model_output.rb
+++ b/lib/chef/http/json_to_model_output.rb
@@ -26,7 +26,7 @@ class Chef
# a `json_class` key.
class JSONToModelOutput < JSONOutput
def initialize(opts = {})
- opts[:inflate_json_class] = true if !opts.key?(:inflate_json_class)
+ opts[:inflate_json_class] = true unless opts.key?(:inflate_json_class)
super
end
end
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 02f38e9f89..86d54ecb98 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -643,7 +643,7 @@ class Chef
end
def maybe_setup_fips
- if !config[:fips].nil?
+ unless config[:fips].nil?
Chef::Config[:fips] = config[:fips]
end
Chef::Config.init_openssl
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 11736e6084..1aeb097991 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -154,7 +154,7 @@ class Chef
upload_set = {}
@name_args.each do |cookbook_name|
begin
- if ! upload_set.key?(cookbook_name)
+ unless upload_set.key?(cookbook_name)
upload_set[cookbook_name] = cookbook_repo[cookbook_name]
if config[:depends]
upload_set[cookbook_name].metadata.dependencies.each_key { |dep| @name_args << dep }
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index fbe56031cb..49f0069ba6 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -96,7 +96,7 @@ class Chef
client_rb << "chef_license \"#{@chef_config[:chef_license]}\"\n"
end
- if !(@chef_config[:config_log_level].nil? || @chef_config[:config_log_level].empty?)
+ unless @chef_config[:config_log_level].nil? || @chef_config[:config_log_level].empty?
client_rb << %Q{log_level :#{@chef_config[:config_log_level]}\n}
end
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index 663db90585..88fb5dfac8 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -203,7 +203,7 @@ class Chef
def edit_data(data, parse_output = true, object_class: nil)
output = Chef::JSONCompat.to_json_pretty(data)
- if !config[:disable_editing]
+ unless config[:disable_editing]
Tempfile.open([ "knife-edit-", ".json" ]) do |tf|
tf.sync = true
tf.puts output
diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb
index bc4b853879..021cf902d5 100644
--- a/lib/chef/knife/deps.rb
+++ b/lib/chef/knife/deps.rb
@@ -67,7 +67,7 @@ class Chef
end
def print_flattened_dependencies(entry, dependencies)
- if !dependencies[entry.path]
+ unless dependencies[entry.path]
dependencies[entry.path] = get_dependencies(entry)
dependencies[entry.path].each do |child|
child_entry = Chef::ChefFS::FileSystem.resolve_path(@root, child)
@@ -78,7 +78,7 @@ class Chef
end
def print_dependencies_tree(entry, dependencies, printed = {}, depth = 0)
- dependencies[entry.path] = get_dependencies(entry) if !dependencies[entry.path]
+ dependencies[entry.path] = get_dependencies(entry) unless dependencies[entry.path]
output "#{' ' * depth}#{format_path(entry)}"
if !printed[entry.path] && (config[:recurse] || depth == 0)
printed[entry.path] = true
@@ -109,13 +109,13 @@ class Chef
result = []
if role["run_list"]
dependencies_from_runlist(role["run_list"]).each do |dependency|
- result << dependency if !result.include?(dependency)
+ result << dependency unless result.include?(dependency)
end
end
if role["env_run_lists"]
role["env_run_lists"].each_pair do |env, run_list|
dependencies_from_runlist(run_list).each do |dependency|
- result << dependency if !result.include?(dependency)
+ result << dependency unless result.include?(dependency)
end
end
end
diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb
index 406782ef85..e1e9ee1b0d 100644
--- a/lib/chef/knife/edit.rb
+++ b/lib/chef/knife/edit.rb
@@ -66,14 +66,14 @@ class Chef
end
def edit_text(text, extension)
- if !config[:disable_editing]
+ unless config[:disable_editing]
Tempfile.open([ "knife-edit-", extension ]) do |file|
# Write the text to a temporary file
file.write(text)
file.close
# Let the user edit the temporary file
- if !system("#{config[:editor]} #{file.path}")
+ unless system("#{config[:editor]} #{file.path}")
raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup.html for details."
end
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index 78cf238848..26d1bb6458 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -290,7 +290,7 @@ class Chef
port ||= ssh_config[:port]
opts[:port] = port unless port.nil?
opts[:logger] = Chef::Log.with_child(subsystem: "net/ssh") if Chef::Log.level == :trace
- if !config[:host_key_verify]
+ unless config[:host_key_verify]
opts[:verify_host_key] = false
opts[:user_known_hosts_file] = "/dev/null"
end
@@ -598,7 +598,7 @@ class Chef
@password = config[:ssh_password] if config[:ssh_password]
# If a password was not given, check for SSH identity file.
- if !@password
+ unless @password
configure_ssh_identity_file
configure_ssh_gateway_identity
end
diff --git a/lib/chef/knife/supermarket_share.rb b/lib/chef/knife/supermarket_share.rb
index b4fd933fa1..51e8d3dbe5 100644
--- a/lib/chef/knife/supermarket_share.rb
+++ b/lib/chef/knife/supermarket_share.rb
@@ -150,7 +150,7 @@ class Chef
end
def tar_cmd
- if !@tar_cmd
+ unless @tar_cmd
@tar_cmd = "tar"
begin
# Unix and Mac only - prefer gnutar
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
diff --git a/lib/chef/node/common_api.rb b/lib/chef/node/common_api.rb
index 229103556b..1ea1067113 100644
--- a/lib/chef/node/common_api.rb
+++ b/lib/chef/node/common_api.rb
@@ -36,7 +36,7 @@ class Chef
last = args.pop
prev_memo = prev_key = nil
chain = args.inject(self) do |memo, key|
- if !valid_container?(memo, key)
+ unless valid_container?(memo, key)
prev_memo[prev_key] = {}
memo = prev_memo[prev_key]
end
@@ -44,7 +44,7 @@ class Chef
prev_key = key
memo[key]
end
- if !valid_container?(chain, last)
+ unless valid_container?(chain, last)
prev_memo[prev_key] = {}
chain = prev_memo[prev_key]
end
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index c2715965eb..dd118c26cf 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -227,7 +227,7 @@ class Chef
def matches_black_white_list?(node, filters, attribute)
# It's super common for the filter to be nil. Catch that so we don't
# spend any time here.
- return true if !filters[attribute]
+ return true unless filters[attribute]
filter_values = Array(filters[attribute])
value = node[attribute]
@@ -245,7 +245,7 @@ class Chef
def matches_version_list?(node, filters, attribute)
# It's super common for the filter to be nil. Catch that so we don't
# spend any time here.
- return true if !filters[attribute]
+ return true unless filters[attribute]
filter_values = Array(filters[attribute])
value = node[attribute]
@@ -281,7 +281,7 @@ class Chef
end
def node_matches?(node, matcher)
- return true if !node
+ return true unless node
filters_match?(node, matcher) && block_matches?(node, matcher[:block])
end
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 5c9a62bed2..6aa76a5236 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -261,7 +261,7 @@ class Chef
# @return [Boolean]
#
def desired_state?
- return true if !options.key?(:desired_state)
+ return true unless options.key?(:desired_state)
options[:desired_state]
end
@@ -554,7 +554,7 @@ class Chef
def emit_dsl
# We don't create the getter/setter if it's a custom property; we will
# be using the existing getter/setter to manipulate it instead.
- return if !instance_variable_name
+ return unless instance_variable_name
# Properties may override existing properties up the inheritance heirarchy, but
# properties must not override inherited methods like Object#hash. When the Resource is
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 641d8559d8..97e3a310e5 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -266,7 +266,7 @@ class Chef
# @return [Boolean] whether the block was executed.
#
def converge_if_changed(*properties, &converge_block)
- if !converge_block
+ unless converge_block
raise ArgumentError, "converge_if_changed must be passed a block!"
end
diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb
index 7ba7c16b9f..8914d5412b 100644
--- a/lib/chef/provider/apt_update.rb
+++ b/lib/chef/provider/apt_update.rb
@@ -31,7 +31,7 @@ class Chef
def load_current_resource; end
action :periodic do
- if !apt_up_to_date?
+ unless apt_up_to_date?
converge_by "update new lists of packages" do
do_update
end
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index 94d3b31d0a..da8b17ed04 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -34,7 +34,7 @@ class Chef
end
def action_run
- if ! test_resource
+ unless test_resource
converge_by(generate_description) do
result = set_resource
reboot_if_required
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index d7ac9689ef..bffd9812f2 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -41,7 +41,7 @@ class Chef
end
def action_run
- if ! @resource_converged
+ unless @resource_converged
converge_by(generate_description) do
run_configuration(:set)
logger.info("DSC resource configuration completed successfully")
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index ca5f11ba43..0cd866d84b 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -90,7 +90,7 @@ class Chef
@current_resource ||= Chef::Resource::File.new(new_resource.name)
current_resource.path(new_resource.path)
- if !needs_creating?
+ unless needs_creating?
# we are updating an existing file
if managing_content?
logger.trace("#{new_resource} checksumming file at #{new_resource.path}.")
@@ -340,7 +340,7 @@ class Chef
if tempfile
new_resource.verify.each do |v|
- if ! v.verify(tempfile.path)
+ unless v.verify(tempfile.path)
raise Chef::Exceptions::ValidationFailed.new "Proposed content for #{new_resource.path} failed verification #{new_resource.sensitive ? '[sensitive]' : v}"
end
end
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb
index 68a4552bab..ca6ca4bd63 100644
--- a/lib/chef/provider/mount/aix.rb
+++ b/lib/chef/provider/mount/aix.rb
@@ -123,7 +123,7 @@ class Chef
mountable?
command = [ "mount", "-v", @new_resource.fstype ]
- if !(@new_resource.options.nil? || @new_resource.options.empty?)
+ unless @new_resource.options.nil? || @new_resource.options.empty?
command << "-o"
command << @new_resource.options.join(",")
end
@@ -203,7 +203,7 @@ class Chef
found_device = false
end
end
- if !found_device
+ unless found_device
contents << line
end
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index 08a9c857c9..d5d6e76fa5 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -156,7 +156,7 @@ class Chef
# this will resolve things like `/usr/bin/perl` or virtual packages like `mysql` -- it will not work (well? at all?) with globs that match multiple packages
def resolved_package_lock_names(names)
names.each_with_index.map do |name, i|
- if !name.nil?
+ unless name.nil?
if installed_version(i).version.nil?
available_version(i).name
else
diff --git a/lib/chef/provider/remote_file/fetcher.rb b/lib/chef/provider/remote_file/fetcher.rb
index 282309301d..85318b1df7 100644
--- a/lib/chef/provider/remote_file/fetcher.rb
+++ b/lib/chef/provider/remote_file/fetcher.rb
@@ -24,7 +24,7 @@ class Chef
def self.for_resource(uri, new_resource, current_resource)
if network_share?(uri)
- if !Chef::Platform.windows?
+ unless Chef::Platform.windows?
raise Exceptions::UnsupportedPlatform, "Fetching the file on a network share is supported only on the Windows platform. Please change your source: #{uri}"
end
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 3f28e69ce3..e427606571 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -78,7 +78,7 @@ class Chef
end
def enable_service
- if !is_enabled?
+ unless is_enabled?
if is_builtin?
if is_enabled_by_default?
update_rcl rc_conf_local.sub(/^#{Regexp.escape(builtin_service_enable_variable_name)}=.*/, "")
@@ -132,7 +132,7 @@ class Chef
end
def update_rcl(value)
- FileUtils.touch RC_CONF_LOCAL_PATH if !::File.exists? RC_CONF_LOCAL_PATH
+ FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exists? RC_CONF_LOCAL_PATH
::File.write(RC_CONF_LOCAL_PATH, value)
@rc_conf_local = value
end
@@ -170,7 +170,7 @@ class Chef
var_name = builtin_service_enable_variable_name
if var_name
if m = rc_conf.match(/^#{Regexp.escape(var_name)}=(.*)/)
- if !(m[1] =~ /"?[Nn][Oo]"?/)
+ unless m[1] =~ /"?[Nn][Oo]"?/
result = true
end
end
@@ -186,12 +186,12 @@ class Chef
if var_name
if m = rc_conf_local.match(/^#{Regexp.escape(var_name)}=(.*)/)
@enabled_state_found = true
- if !(m[1] =~ /"?[Nn][Oo]"?/) # e.g. looking for httpd_flags=NO
+ unless m[1] =~ /"?[Nn][Oo]"?/ # e.g. looking for httpd_flags=NO
result = true
end
end
end
- if !@enabled_state_found
+ unless @enabled_state_found
result = is_enabled_by_default?
end
else
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index d88dc4bb6f..5364053ba8 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -83,7 +83,7 @@ class Chef
# Do not call super, only call shared requirements
shared_resource_requirements
requirements.assert(:all_actions) do |a|
- if !@command_success
+ unless @command_success
whyrun_msg = if @new_resource.status_command
"Provided status command #{@new_resource.status_command} failed."
else
diff --git a/lib/chef/provider/windows_script.rb b/lib/chef/provider/windows_script.rb
index 56651a23a6..172b07d712 100644
--- a/lib/chef/provider/windows_script.rb
+++ b/lib/chef/provider/windows_script.rb
@@ -58,7 +58,7 @@ class Chef
rescue
raise
ensure
- if ! wow64_redirection_state.nil?
+ unless wow64_redirection_state.nil?
restore_wow64_file_redirection(@run_context.node, wow64_redirection_state)
end
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index eea44e5c69..6e2c139456 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -835,7 +835,7 @@ class Chef
#
def self.identity_attr(name = nil)
property = identity_property(name)
- return nil if !property
+ return nil unless property
property.name
end
@@ -957,7 +957,7 @@ class Chef
if name
name = name.to_sym
# If our class is not already providing this name, provide it.
- if !Chef::ResourceResolver.includes_handler?(name, self)
+ unless Chef::ResourceResolver.includes_handler?(name, self)
provides name, canonical: true
end
@resource_name = name
@@ -1589,7 +1589,7 @@ class Chef
def self.remove_canonical_dsl
if @resource_name
remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
- if !remaining
+ unless remaining
Chef::DSL::Resources.remove_resource_dsl(@resource_name)
end
end
diff --git a/lib/chef/resource/dnf_package.rb b/lib/chef/resource/dnf_package.rb
index 52c739beb9..c90e135335 100644
--- a/lib/chef/resource/dnf_package.rb
+++ b/lib/chef/resource/dnf_package.rb
@@ -70,7 +70,7 @@ class Chef
}
def allow_downgrade(arg = nil)
- if !arg.nil?
+ unless arg.nil?
Chef.deprecated(:dnf_package_allow_downgrade, "the allow_downgrade property on the dnf_package provider is not used, DNF supports downgrades by default.")
end
false
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index 3ccc30f0fb..c2965944ec 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -77,7 +77,7 @@ class Chef
description: "The version number of the module to use. PowerShell 5.0.10018.0 (or higher) supports having multiple versions of a module installed. This should be specified along with the module_name."
def property(property_name, value = nil)
- if not property_name.is_a?(Symbol)
+ unless property_name.is_a?(Symbol)
raise TypeError, "A property name of type Symbol must be specified, '#{property_name}' of type #{property_name.class} was given"
end
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index 47fd9cada7..8cfbe47358 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -78,7 +78,7 @@ class Chef
property :verifications, Array, default: lazy { [] }
def verify(command = nil, opts = {}, &block)
- if ! (command.nil? || [String, Symbol].include?(command.class))
+ unless command.nil? || [String, Symbol].include?(command.class)
raise ArgumentError, "verify requires either a string, symbol, or a block"
end
diff --git a/lib/chef/resource/resource_notification.rb b/lib/chef/resource/resource_notification.rb
index 4bcadca60a..f9cad8232f 100644
--- a/lib/chef/resource/resource_notification.rb
+++ b/lib/chef/resource/resource_notification.rb
@@ -55,11 +55,11 @@ class Chef
def resolve_resource_reference(resource_collection)
return resource if resource.kind_of?(Chef::Resource) && notifying_resource.kind_of?(Chef::Resource)
- if not(resource.kind_of?(Chef::Resource))
+ unless resource.kind_of?(Chef::Resource)
fix_resource_reference(resource_collection)
end
- if not(notifying_resource.kind_of?(Chef::Resource))
+ unless notifying_resource.kind_of?(Chef::Resource)
fix_notifier_reference(resource_collection)
end
end
diff --git a/lib/chef/resource/windows_script.rb b/lib/chef/resource/windows_script.rb
index 3177a32090..c542fbd81b 100644
--- a/lib/chef/resource/windows_script.rb
+++ b/lib/chef/resource/windows_script.rb
@@ -41,7 +41,7 @@ class Chef
public
def architecture(arg = nil)
- assert_architecture_compatible!(arg) if ! arg.nil?
+ assert_architecture_compatible!(arg) unless arg.nil?
result = set_or_return(
:architecture,
arg,
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index 0652708f70..034e9484a4 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -91,7 +91,7 @@ class Chef
# Per environment run lists
def env_run_lists(env_run_lists = nil)
- if !env_run_lists.nil?
+ unless env_run_lists.nil?
unless env_run_lists.key?("_default")
msg = "_default key is required in env_run_lists.\n"
msg << "(env_run_lists: #{env_run_lists.inspect})"
@@ -106,7 +106,7 @@ class Chef
alias :env_run_list :env_run_lists
def env_run_lists_add(env_run_lists = nil)
- if !env_run_lists.nil?
+ unless env_run_lists.nil?
env_run_lists.each { |k, v| @env_run_lists[k] = Chef::RunList.new(*Array(v)) }
end
@env_run_lists
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 467b2997fd..e0a3698e1b 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -373,7 +373,7 @@ class Chef
# @raise [Chef::Exceptions::RecipeNotFound] If the file does not exist.
#
def load_recipe_file(recipe_file)
- if !File.exist?(recipe_file)
+ unless File.exist?(recipe_file)
raise Chef::Exceptions::RecipeNotFound, "could not find recipe file #{recipe_file}"
end
@@ -710,7 +710,7 @@ class Chef
# Verify that we didn't miss any methods
unless @__skip_method_checking # hook specifically for compat_resource
missing_methods = superclass.instance_methods(false) - instance_methods(false) - CHILD_STATE
- if !missing_methods.empty?
+ unless missing_methods.empty?
raise "ERROR: not all methods of RunContext accounted for in ChildRunContext! All methods must be marked as child methods with CHILD_STATE or delegated to the parent_run_context. Missing #{missing_methods.join(", ")}."
end
end
diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb
index a00c703c76..bc331d7971 100644
--- a/lib/chef/util/dsc/configuration_generator.rb
+++ b/lib/chef/util/dsc/configuration_generator.rb
@@ -47,7 +47,7 @@ class Chef::Util::DSC
document_generation_cmdlet.run!(merged_configuration_flags, shellout_flags)
configuration_document_location = find_configuration_document(configuration_name)
- if ! configuration_document_location
+ unless configuration_document_location
raise "No DSC configuration for '#{configuration_name}' was generated from supplied DSC script"
end
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index 72657a6d55..75cf489e9e 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -89,7 +89,7 @@ class Chef
def run!(switches = {}, execution_options = {}, *arguments)
result = run(switches, execution_options, arguments)
- if ! result.succeeded?
+ unless result.succeeded?
raise Chef::Exceptions::PowershellCmdletException, "PowerShell Cmdlet failed: #{result.stderr}"
end
diff --git a/lib/chef/util/windows/logon_session.rb b/lib/chef/util/windows/logon_session.rb
index 2e1f19b001..b7db9da51c 100644
--- a/lib/chef/util/windows/logon_session.rb
+++ b/lib/chef/util/windows/logon_session.rb
@@ -51,7 +51,7 @@ class Chef
logon_type = (authentication == :local) ? (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NETWORK) : (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS)
status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, logon_type, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token)
- if !status
+ unless status
last_error = FFI::LastError.error
raise Chef::Exceptions::Win32APIError, "Logon for user `#{original_username}` failed with Win32 status #{last_error}."
end
@@ -74,7 +74,7 @@ class Chef
def set_user_context
validate_session_open!
- if ! session_opened
+ unless session_opened
raise "Attempted to set the user context before opening a session."
end
@@ -84,7 +84,7 @@ class Chef
status = Chef::ReservedNames::Win32::API::Security.ImpersonateLoggedOnUser(token.read_ulong)
- if !status
+ unless status
last_error = FFI::LastError.error
raise Chef::Exceptions::Win32APIError, "Attempt to impersonate user `#{original_username}` failed with Win32 status #{last_error}."
end
@@ -98,7 +98,7 @@ class Chef
if impersonating
status = Chef::ReservedNames::Win32::API::Security.RevertToSelf
- if !status
+ unless status
last_error = FFI::LastError.error
raise Chef::Exceptions::Win32APIError, "Unable to restore user context with Win32 status #{last_error}."
end
@@ -119,7 +119,7 @@ class Chef
attr_reader :impersonating
def validate_session_open!
- if ! session_opened
+ unless session_opened
raise "Attempted to set the user context before opening a session."
end
end
diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb
index 4997c0c4c0..ca15acf3d8 100644
--- a/lib/chef/win32/eventlog.rb
+++ b/lib/chef/win32/eventlog.rb
@@ -17,7 +17,7 @@
#
if Chef::Platform.windows?
- if !defined? Chef::Win32EventLogLoaded
+ unless defined? Chef::Win32EventLogLoaded
if defined? Windows::Constants
%i{INFINITE WAIT_FAILED FORMAT_MESSAGE_IGNORE_INSERTS ERROR_INSUFFICIENT_BUFFER}.each do |c|
# These are redefined in 'win32/eventlog'
diff --git a/lib/chef/win32/memory.rb b/lib/chef/win32/memory.rb
index 853551f183..1ea6375e01 100644
--- a/lib/chef/win32/memory.rb
+++ b/lib/chef/win32/memory.rb
@@ -67,7 +67,7 @@ class Chef
# Free memory allocated using local_alloc
def self.local_free(pointer)
result = LocalFree(pointer)
- if !result.null?
+ unless result.null?
Chef::ReservedNames::Win32::Error.raise!
end
end
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 94311f7954..90bc35143a 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -361,7 +361,7 @@ class Chef
hive, key = get_hive_and_key(key_path)
missing_key_arr.each do |intermediate_key|
existing_key_path = existing_key_path << "\\" << intermediate_key
- if !key_exists?(existing_key_path)
+ unless key_exists?(existing_key_path)
Chef::Log.trace("Recursively creating registry key #{existing_key_path}")
hive.create(get_key(existing_key_path), ::Win32::Registry::KEY_ALL_ACCESS | registry_system_architecture)
end
diff --git a/lib/chef/win32/security/security_descriptor.rb b/lib/chef/win32/security/security_descriptor.rb
index 722d8faf5d..3d109e60bb 100644
--- a/lib/chef/win32/security/security_descriptor.rb
+++ b/lib/chef/win32/security/security_descriptor.rb
@@ -41,7 +41,7 @@ class Chef
end
def dacl
- raise "DACL not present" if !dacl_present?
+ raise "DACL not present" unless dacl_present?
present, acl, defaulted = Chef::ReservedNames::Win32::Security.get_security_descriptor_dacl(self)
acl
@@ -66,7 +66,7 @@ class Chef
end
def sacl
- raise "SACL not present" if !sacl_present?
+ raise "SACL not present" unless sacl_present?
Security.with_privileges("SeSecurityPrivilege") do
present, acl, defaulted = Chef::ReservedNames::Win32::Security.get_security_descriptor_sacl(self)
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 343e4f2f4e..f5bb458666 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -96,7 +96,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
end
def create_user(username, uid = nil)
- if ! windows_domain_user?(username)
+ unless windows_domain_user?(username)
user_to_create = user(username)
user_to_create.uid(uid) if uid
user_to_create.run_action(:create)
@@ -105,7 +105,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
end
def remove_user(username)
- if ! windows_domain_user?(username)
+ unless windows_domain_user?(username)
u = user(username)
u.manage_home false # jekins hosts throw mail spool file not owned by user if we use manage_home true
u.run_action(:remove)
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 825f2810d4..d9a8bd2d0e 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -347,7 +347,7 @@ describe Chef::RunLock do
example.log_event("#{name}.run_to(#{to_event.inspect})")
# Start the process if it's not started
- start if !pid
+ start unless pid
# Tell the process what to stop at (also means it can go)
write_to_process.print "#{to_event}\n"
@@ -371,7 +371,7 @@ describe Chef::RunLock do
def run_to_completion
example.log_event("#{name}.run_to_completion")
# Start the process if it's not started
- start if !pid
+ start unless pid
# Tell the process to stop at nothing (no blocking)
@write_to_process.print "nothing\n"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index ac5f68b484..ee486e919c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -145,7 +145,7 @@ RSpec.configure do |config|
config.filter_run_excluding windows_only: true unless windows?
config.filter_run_excluding not_supported_on_windows: true if windows?
config.filter_run_excluding not_supported_on_macos: true if mac_osx?
- config.filter_run_excluding macos_only: true if !mac_osx?
+ config.filter_run_excluding macos_only: true unless mac_osx?
config.filter_run_excluding not_supported_on_aix: true if aix?
config.filter_run_excluding not_supported_on_solaris: true if solaris?
config.filter_run_excluding not_supported_on_gce: true if gce?
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 84fc71cc99..72dd67ca97 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -25,7 +25,7 @@ class Chef
provides :follower, platform: "zen"
def master(arg = nil)
- if !arg.nil?
+ unless arg.nil?
@master = arg
end
@master
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 9d6e5d46f7..710742a285 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -30,7 +30,7 @@ class Chef
end
def something(arg = nil)
- if !arg.nil?
+ unless arg.nil?
@something = arg
end
@something
diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb
index 5b30c567cc..7398cfbd96 100644
--- a/spec/support/platforms/win32/spec_service.rb
+++ b/spec/support/platforms/win32/spec_service.rb
@@ -25,7 +25,7 @@ class SpecService < ::Win32::Daemon
def service_main(*startup_parameters)
while running?
- if !File.exists?(@test_service_file)
+ unless File.exists?(@test_service_file)
File.open(@test_service_file, "wb") do |f|
f.write("This file is created by SpecService")
end
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index 87ce1bc0b0..56933537f0 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -150,7 +150,7 @@ module KnifeSupport
expected[:stderr] = arg
end
end
- expected[:exit_code] = 1 if !expected[:exit_code]
+ expected[:exit_code] = 1 unless expected[:exit_code]
should_result_in(expected)
end
@@ -169,9 +169,9 @@ module KnifeSupport
private
def should_result_in(expected)
- expected[:stdout] = "" if !expected[:stdout]
- expected[:stderr] = "" if !expected[:stderr]
- expected[:exit_code] = 0 if !expected[:exit_code]
+ expected[:stdout] = "" unless expected[:stdout]
+ expected[:stderr] = "" unless expected[:stderr]
+ expected[:exit_code] = 0 unless expected[:exit_code]
# TODO make this go away
stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, "")
diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb
index 80cc7cdc23..957479f149 100644
--- a/spec/support/shared/unit/file_system_support.rb
+++ b/spec/support/shared/unit/file_system_support.rb
@@ -23,7 +23,7 @@ require "chef/chef_fs/file_system/memory/memory_file"
module FileSystemSupport
def memory_fs(pretty_name, value, cannot_be_in_regex = nil)
- if !value.is_a?(Hash)
+ unless value.is_a?(Hash)
raise "memory_fs() must take a Hash"
end
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 7d4e18d23c..ad7bee0ec9 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -67,7 +67,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do
it "returns true only when forced_32bit_override_required? has 64-bit node architecture and 32-bit desired architecture" do
with_node_architecture_combinations do |node, desired_arch|
expect(forced_32bit_override_required?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows?
- expect(forced_32bit_override_required?(node, desired_arch)).to be false if ! ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386))
+ expect(forced_32bit_override_required?(node, desired_arch)).to be false unless (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386)
end
end
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index be4df761d2..cca0f34067 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
node = Chef::Node.new
node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
- if ! powershell_version.nil?
+ unless powershell_version.nil?
node.default[:languages] = { powershell: { version: powershell_version } }
end
node
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index 9014b873de..94e0d6074b 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -869,7 +869,7 @@ describe Chef::ProviderResolver do
def self.create_provider_tests(providers, test, expected, filter)
expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) })
providers.each do |key, value|
- if !key.is_a?(Symbol)
+ unless key.is_a?(Symbol)
next_test = test.merge({ filter => key })
next_filter =
case filter
@@ -888,7 +888,7 @@ describe Chef::ProviderResolver do
end
end
# If there is no filter, we're as deep as we need to go
- if !filter
+ unless filter
on_platform test.delete(:platform), test do
expect_providers(expected)
end