Skip to content

Commit

Permalink
Merge pull request #4671 from mzazrivec/dont_use_conditions_inside_st…
Browse files Browse the repository at this point in the history
…ring_interpolation

Don't use if/unless inside a string interpolation
  • Loading branch information
martinpovolny authored Oct 2, 2018
2 parents 11a2c24 + 3fd9532 commit 97a1fa3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -686,15 +686,15 @@ def build_audit_msg(new, current, msg_in)
if !k.to_s.ends_with?("password2", "verify") &&
(current.nil? || (new[k] != current[k]))
if password_field?(k) # Asterisk out password fields
msg_arr << "#{k}:[*]#{' to [*]' unless current.nil?}"
msg_arr << "#{k}:[*]" + (current.nil? ? '' : ' to [*]')
elsif new[k].kind_of?(Hash) # If the field is a hash,
# Make current a blank hash for following comparisons
current[k] = {} if !current.nil? && current[k].nil?
# process keys of the current and new hashes
(new[k].keys | (current.nil? ? [] : current[k].keys)).each do |hk|
next if current.present? && (new[k][hk] == current[k][hk])
msg_arr << if password_field?(hk) # Asterisk out password fields
"#{hk}:[*]#{' to [*]' unless current.nil?}"
"#{hk}:[*]" + (current.nil? ? '' : ' to [*]')
else
"#{hk}:[" + (current.nil? ? "" : "#{filter_config(current[k][hk])}] to [") +
"#{filter_config(new[k][hk])}]"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/report_controller/reports/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def gfv_sort
sort, suffix = @edit[:new][:sortby1].split("__")
@edit[:new][:col_options][sort1][:break_label] =
@edit[:new][:field_order].collect { |f| f.first if f.last == sort }.compact.join.strip +
(suffix ? " (#{MiqReport.date_time_break_suffixes.collect { |s| s.first if s.last == suffix }.compact.join})" : "") +
(suffix ? " (%{suffixes})" % {:suffixes => MiqReport.date_time_break_suffixes.collect { |s| s.first if s.last == suffix }.compact.join} : "") +
": "
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/vm_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def textual_storage
main = @record.storage
h[:value] = storages.sort_by { |s| s.name.downcase }.collect do |s|
{:icon => "fa fa-database",
:value => "#{s.name}#{" (main)" if s == main}",
:value => s.name + (s == main ? ' (main)' : ''),
:title => _("Show this VM's Datastores"),
:link => url_for_only_path(:controller => 'storage', :action => 'show', :id => s)}
end
Expand Down

0 comments on commit 97a1fa3

Please sign in to comment.