summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-05 17:34:56 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-05 17:34:56 -0700
commit777d8183baf58f6f3fbc8befe51c8801d76beb74 (patch)
tree02d07e6187b6a90b32dd6bfde79ddb5521913ce5
parent46fb8800fb67506f52cdcdb3f7d6f8fae480cffe (diff)
downloadchef-rubocop_Style_RedundantAssignment.tar.gz
Resolve Style/RedundantAssignment warningsrubocop_Style_RedundantAssignment
Avoid assigning when we don't need to Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb12
-rw-r--r--lib/chef/node/attribute.rb6
-rw-r--r--lib/chef/resource_collection/stepable_iterator.rb3
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