From 640561e3494bd4bf916c78cb5633dd5ffac0fb3c Mon Sep 17 00:00:00 2001 From: akumari Date: Wed, 6 Mar 2024 15:49:16 +0530 Subject: [PATCH] Fix Style/RedundantAssignment cop This cop efficiently detects and fixes unnecessary variable assignments before returning values in methods. Also improves redability of code by reducing clutter. https://docs.rubocop.org/rubocop/cops_style.html#styleredundantassignment --- app/helpers/form_helper.rb | 3 +-- app/models/compute_resource.rb | 3 +-- app/models/host/managed.rb | 3 +-- app/services/proxy_reference_registry.rb | 3 +-- script/dynflowd | 4 ++-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 6f4164bd4508..4aa9a14931d6 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -317,8 +317,7 @@ def add_label(options, f, attr) if options[:label_help].present? label += ' '.html_safe + popover("", options[:label_help], options[:label_help_options] || {}) end - label = label.present? ? label_tag(attr, label.to_s + required_mark.to_s, :class => label_size + " control-label") : '' - label + label.present? ? label_tag(attr, label.to_s + required_mark.to_s, :class => label_size + " control-label") : '' end def check_required(options, f, attr) diff --git a/app/models/compute_resource.rb b/app/models/compute_resource.rb index a555156e9bd7..00a127b435cf 100644 --- a/app/models/compute_resource.rb +++ b/app/models/compute_resource.rb @@ -375,8 +375,7 @@ def vm_compute_attributes(vm) vm_attrs = vm_attrs.reject { |k, v| k == :id } vm_attrs = set_vm_volumes_attributes(vm, vm_attrs) - vm_attrs = set_vm_interfaces_attributes(vm, vm_attrs) - vm_attrs + set_vm_interfaces_attributes(vm, vm_attrs) end def vm_ready(vm) diff --git a/app/models/host/managed.rb b/app/models/host/managed.rb index e63032e5a5b2..cd3368202809 100644 --- a/app/models/host/managed.rb +++ b/app/models/host/managed.rb @@ -534,8 +534,7 @@ def apply_inherited_attributes(attributes, initialized = true) attributes[attribute] = value end - attributes = apply_facet_attributes(new_hostgroup, attributes) - attributes + apply_facet_attributes(new_hostgroup, attributes) end def hash_clone(value) diff --git a/app/services/proxy_reference_registry.rb b/app/services/proxy_reference_registry.rb index 9d8c9d958c1a..40ae5f1b0749 100644 --- a/app/services/proxy_reference_registry.rb +++ b/app/services/proxy_reference_registry.rb @@ -44,8 +44,7 @@ def join_reference_arrays(references, other_references) end memo end - references = references.concat to_add - references + references.concat to_add end private diff --git a/script/dynflowd b/script/dynflowd index d3a47b58ad3d..89aa9772c520 100755 --- a/script/dynflowd +++ b/script/dynflowd @@ -37,7 +37,7 @@ class ArgvParser end def banner(file) - banner = <<~BANNER + <<~BANNER Run Dynflow executor for Foreman tasks. Usage: #{File.basename(file)} [options] ACTION" @@ -56,7 +56,7 @@ class ArgvParser * run - run the executor in foreground BANNER - banner + end end