Skip to content

Commit b469532

Browse files
committed
Replace Hash#merge! with Hash#[]= (#34160).
git-svn-id: http://svn.redmine.org/redmine/trunk@20175 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent 52cc3fd commit b469532

12 files changed

+30
-46
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -564,22 +564,6 @@ Performance/RedundantMatch:
564564
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
565565
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
566566

567-
# Cop supports --auto-correct.
568-
# Configuration parameters: MaxKeyValuePairs.
569-
Performance/RedundantMerge:
570-
Exclude:
571-
- 'app/controllers/issues_controller.rb'
572-
- 'app/helpers/application_helper.rb'
573-
- 'app/helpers/avatars_helper.rb'
574-
- 'app/helpers/custom_fields_helper.rb'
575-
- 'app/helpers/workflows_helper.rb'
576-
- 'app/models/auth_source_ldap.rb'
577-
- 'app/models/principal.rb'
578-
- 'lib/redmine/access_control.rb'
579-
- 'test/functional/imports_controller_test.rb'
580-
- 'test/unit/issue_import_test.rb'
581-
- 'test/unit/time_entry_import_test.rb'
582-
583567
# Cop supports --auto-correct.
584568
Performance/Squeeze:
585569
Exclude:

app/controllers/issues_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def redirect_after_create
666666
if params[:project_id]
667667
redirect_to new_project_issue_path(@issue.project, url_params)
668668
else
669-
url_params[:issue].merge! :project_id => @issue.project_id
669+
url_params[:issue][:project_id] = @issue.project_id
670670
redirect_to new_issue_path(url_params)
671671
end
672672
else

app/helpers/application_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,16 +1401,16 @@ def labelled_form_for(*args, &proc)
14011401
args << {} unless args.last.is_a?(Hash)
14021402
options = args.last
14031403
if args.first.is_a?(Symbol)
1404-
options.merge!(:as => args.shift)
1404+
options[:as] = args.shift
14051405
end
1406-
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
1406+
options[:builder] = Redmine::Views::LabelledFormBuilder
14071407
form_for(*args, &proc)
14081408
end
14091409

14101410
def labelled_fields_for(*args, &proc)
14111411
args << {} unless args.last.is_a?(Hash)
14121412
options = args.last
1413-
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
1413+
options[:builder] = Redmine::Views::LabelledFormBuilder
14141414
fields_for(*args, &proc)
14151415
end
14161416

app/helpers/avatars_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ module AvatarsHelper
2323
def assignee_avatar(user, options={})
2424
return '' unless user
2525

26-
options.merge!(:title => l(:field_assigned_to) + ": " + user.name)
26+
options[:title] = l(:field_assigned_to) + ": " + user.name
2727
avatar(user, options).to_s.html_safe
2828
end
2929

3030
def author_avatar(user, options={})
3131
return '' unless user
3232

33-
options.merge!(:title => l(:field_author) + ": " + user.name)
33+
options[:title] = l(:field_author) + ": " + user.name
3434
avatar(user, options).to_s.html_safe
3535
end
3636

3737
# Returns the avatar image tag for the given +user+ if avatars are enabled
3838
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <[email protected]>')
3939
def avatar(user, options = { })
4040
if Setting.gravatar_enabled?
41-
options.merge!(:default => Setting.gravatar_default)
41+
options[:default] = Setting.gravatar_default
4242
options[:class] = GravatarHelper::DEFAULT_OPTIONS[:class] + " " + options[:class] if options[:class]
4343
email = nil
4444
if user.respond_to?(:mail)

app/helpers/custom_fields_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def render_api_custom_values(custom_values, api)
190190
api.array :custom_fields do
191191
custom_values.each do |custom_value|
192192
attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name}
193-
attrs.merge!(:multiple => true) if custom_value.custom_field.multiple?
193+
attrs[:multiple] = true if custom_value.custom_field.multiple?
194194
api.custom_field attrs do
195195
if custom_value.value.is_a?(Array)
196196
api.array :value do

app/helpers/workflows_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def options_for_workflow_select(name, objects, selected, options={})
3535
end
3636
all_tag_options = {:value => 'all', :selected => (selected == 'all')}
3737
if multiple
38-
all_tag_options.merge!(:style => "display:none;")
38+
all_tag_options[:style] = "display:none;"
3939
end
4040
option_tags << content_tag('option', l(:label_all), all_tag_options)
4141
option_tags << options_from_collection_for_select(objects, "id", "name", selected)

app/models/auth_source_ldap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def initialize_ldap_con(ldap_user, ldap_password)
187187
}
188188
end
189189
unless ldap_user.blank? && ldap_password.blank?
190-
options.merge!(:auth => {:method => :simple, :username => ldap_user, :password => ldap_password})
190+
options[:auth] = {:method => :simple, :username => ldap_user, :password => ldap_password}
191191
end
192192
Net::LDAP.new options
193193
end

app/models/principal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Principal < ActiveRecord::Base
8080
if tokens.present?
8181
sql << ' OR ('
8282
sql << tokens.map.with_index do |token, index|
83-
params.merge!(:"token_#{index}" => token)
83+
params[:"token_#{index}"] = token
8484
"(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}))"
8585
end.join(' AND ')
8686
sql << ')'

lib/redmine/access_control.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def initialize
8484

8585
def permission(name, hash, options={})
8686
@permissions ||= []
87-
options.merge!(:project_module => @project_module)
87+
options[:project_module] = @project_module
8888
@permissions << Permission.new(name, hash, options)
8989
end
9090

test/functional/imports_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def test_show_without_errors
405405

406406
def test_show_with_errors_should_show_unsaved_items
407407
import = generate_import_with_mapping
408-
import.mapping.merge! 'subject' => 20
408+
import.mapping['subject'] = 20
409409
import.run
410410
assert_not_equal 0, import.unsaved_items.count
411411

0 commit comments

Comments
 (0)