From 9802d7c075c8b7dae42dbcecd92d492f7fa128ac Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 3 Jul 2019 13:11:13 -0700 Subject: Style/NegatedIf Signed-off-by: Lamont Granquist --- lib/chef/util/dsc/configuration_generator.rb | 2 +- lib/chef/util/powershell/cmdlet.rb | 2 +- lib/chef/util/windows/logon_session.rb | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/chef/util') 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 -- cgit v1.2.1