Skip to content

Commit

Permalink
Fix Style/RedundantAssignment cop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
archanaserver committed Mar 6, 2024
1 parent 2233c33 commit 640561e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions app/models/compute_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions app/models/host/managed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions app/services/proxy_reference_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions script/dynflowd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -56,7 +56,7 @@ class ArgvParser
* run - run the executor in foreground
BANNER
banner

end
end

Expand Down

0 comments on commit 640561e

Please sign in to comment.