From 777d8183baf58f6f3fbc8befe51c8801d76beb74 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 5 Aug 2020 17:34:56 -0700 Subject: Resolve Style/RedundantAssignment warnings Avoid assigning when we don't need to Signed-off-by: Tim Smith --- chef-config/lib/chef-config/workstation_config_loader.rb | 12 +++++------- lib/chef/node/attribute.rb | 6 ++---- lib/chef/resource_collection/stepable_iterator.rb | 3 +-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb index 846ca674e1..4e44a24fd7 100644 --- a/chef-config/lib/chef-config/workstation_config_loader.rb +++ b/chef-config/lib/chef-config/workstation_config_loader.rb @@ -140,13 +140,11 @@ module ChefConfig end def working_directory - a = if ChefUtils.windows? - env["CD"] - else - env["PWD"] - end || Dir.pwd - - a + if ChefUtils.windows? + env["CD"] + else + env["PWD"] + end || Dir.pwd end def apply_credentials(creds, profile) diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index e9a48d8b0e..29b60a98d5 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -563,11 +563,10 @@ class Chef # @param path [Array] Array of args to method chain to descend into the node object # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object def merge_defaults(path) - ret = DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar| + DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar| component_value = apply_path(instance_variable_get(component_ivar), path) deep_merge!(merged, component_value) end - ret end # Deep merge the override attribute levels with array merging. @@ -577,11 +576,10 @@ class Chef # @param path [Array] Array of args to method chain to descend into the node object # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object def merge_overrides(path) - ret = OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar| + OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar| component_value = apply_path(instance_variable_get(component_ivar), path) deep_merge!(merged, component_value) end - ret end # needed for __path__ diff --git a/lib/chef/resource_collection/stepable_iterator.rb b/lib/chef/resource_collection/stepable_iterator.rb index d010c29be5..24a8f676d5 100644 --- a/lib/chef/resource_collection/stepable_iterator.rb +++ b/lib/chef/resource_collection/stepable_iterator.rb @@ -20,8 +20,7 @@ class Chef class StepableIterator def self.for_collection(new_collection) - instance = new(new_collection) - instance + new(new_collection) end attr_accessor :collection -- cgit v1.2.1