summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <454857+lamont-granquist@users.noreply.github.com>2022-01-04 12:42:25 -0800
committerGitHub <noreply@github.com>2022-01-04 12:42:25 -0800
commit8c5dbeb7609284f79d705e6ff0ac703bce0752ba (patch)
tree36339b903de57c92a2abdde9e20e5b0ca55024c8
parent3c02e500ea7eb2f26ddcc07d031c229ca3365391 (diff)
parent96bf96d83cdc799d22ef9e96f4dbc14dc35bebed (diff)
downloadchef-8c5dbeb7609284f79d705e6ff0ac703bce0752ba.tar.gz
Merge pull request #12412 from chef/Performance_RedundantEqualityComparisonBlock
-rw-r--r--lib/chef/application/exit_code.rb28
-rw-r--r--lib/chef/provider/user/mac.rb6
-rw-r--r--lib/chef/resource/launchd.rb4
-rw-r--r--lib/chef/resource/remote_file.rb2
4 files changed, 13 insertions, 27 deletions
diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb
index 26c181fa3d..4cc579e83a 100644
--- a/lib/chef/application/exit_code.rb
+++ b/lib/chef/application/exit_code.rb
@@ -90,45 +90,31 @@ class Chef
end
def reboot_scheduled?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::Reboot
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::Reboot)
end
def reboot_needed?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::RebootPending
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::RebootPending)
end
def reboot_failed?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::RebootFailed
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::RebootFailed)
end
def configuration_failure?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::ConfigurationError
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::ConfigurationError)
end
def client_upgraded?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::ClientUpgraded
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::ClientUpgraded)
end
def sigint_received?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::SigInt
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::SigInt)
end
def sigterm_received?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::SigTerm
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::SigTerm)
end
def resolve_exception_array(exception)
diff --git a/lib/chef/provider/user/mac.rb b/lib/chef/provider/user/mac.rb
index e0e120aa0b..8e5b3d1cf3 100644
--- a/lib/chef/provider/user/mac.rb
+++ b/lib/chef/provider/user/mac.rb
@@ -339,7 +339,7 @@ class Chef
end
def locked?
- user_plist[:auth_authority].any? { |tag| tag == ";DisabledUser;" }
+ user_plist[:auth_authority].any?(";DisabledUser;")
rescue
false
end
@@ -411,7 +411,7 @@ class Chef
end
def secure_token_enabled?
- user_plist[:auth_authority].any? { |tag| tag == ";SecureToken;" }
+ user_plist[:auth_authority].any?(";SecureToken;")
rescue
false
end
@@ -505,7 +505,7 @@ class Chef
end
def admin_user?
- admin_group_plist[:group_members].any? { |mem| mem == user_plist[:guid][0] }
+ admin_group_plist[:group_members].any?(user_plist[:guid][0])
rescue
false
end
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 9729b29085..6a80ada7fa 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -84,7 +84,7 @@ class Chef
end
# Check to make sure that our array only has hashes
- unless array.all? { |obj| obj.is_a?(Hash) }
+ unless array.all?(Hash)
error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
raise Chef::Exceptions::ValidationFailed, error_msg
end
@@ -98,7 +98,7 @@ class Chef
raise Chef::Exceptions::ValidationFailed, error_msg
end
- unless entry.values.all? { |val| val.is_a?(Integer) }
+ unless entry.values.all?(Integer)
failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
raise Chef::Exceptions::ValidationFailed, error_msg
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index bd81b78f73..d91cb86a30 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -138,7 +138,7 @@ class Chef
nil
elsif args[0].is_a?(Chef::DelayedEvaluator) && args.count == 1
args[0]
- elsif args.any? { |a| a.is_a?(Chef::DelayedEvaluator) } && args.count > 1
+ elsif args.any?(Chef::DelayedEvaluator) && args.count > 1
raise Exceptions::InvalidRemoteFileURI, "Only 1 source argument allowed when using a lazy evaluator"
else
Array(args).flatten