diff options
-rw-r--r-- | .rubocop_todo.yml | 16 | ||||
-rw-r--r-- | app/controllers/issues_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/avatars_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/custom_fields_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/workflows_helper.rb | 2 | ||||
-rw-r--r-- | app/models/auth_source_ldap.rb | 2 | ||||
-rw-r--r-- | app/models/principal.rb | 2 | ||||
-rw-r--r-- | lib/redmine/access_control.rb | 2 | ||||
-rw-r--r-- | test/functional/imports_controller_test.rb | 2 | ||||
-rw-r--r-- | test/unit/issue_import_test.rb | 28 | ||||
-rw-r--r-- | test/unit/time_entry_import_test.rb | 6 |
12 files changed, 30 insertions, 46 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eece8b2cc..f225a4535 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -565,22 +565,6 @@ Performance/RedundantMatch: - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' # Cop supports --auto-correct. -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Exclude: - - 'app/controllers/issues_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/avatars_helper.rb' - - 'app/helpers/custom_fields_helper.rb' - - 'app/helpers/workflows_helper.rb' - - 'app/models/auth_source_ldap.rb' - - 'app/models/principal.rb' - - 'lib/redmine/access_control.rb' - - 'test/functional/imports_controller_test.rb' - - 'test/unit/issue_import_test.rb' - - 'test/unit/time_entry_import_test.rb' - -# Cop supports --auto-correct. Performance/Squeeze: Exclude: - 'test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb' diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e2cc1505e..4eb1da96d 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -666,7 +666,7 @@ class IssuesController < ApplicationController if params[:project_id] redirect_to new_project_issue_path(@issue.project, url_params) else - url_params[:issue].merge! :project_id => @issue.project_id + url_params[:issue][:project_id] = @issue.project_id redirect_to new_issue_path(url_params) end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f6317f42..2e54fbefe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1401,16 +1401,16 @@ module ApplicationHelper args << {} unless args.last.is_a?(Hash) options = args.last if args.first.is_a?(Symbol) - options.merge!(:as => args.shift) + options[:as] = args.shift end - options.merge!({:builder => Redmine::Views::LabelledFormBuilder}) + options[:builder] = Redmine::Views::LabelledFormBuilder form_for(*args, &proc) end def labelled_fields_for(*args, &proc) args << {} unless args.last.is_a?(Hash) options = args.last - options.merge!({:builder => Redmine::Views::LabelledFormBuilder}) + options[:builder] = Redmine::Views::LabelledFormBuilder fields_for(*args, &proc) end diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index eb3f01138..c37082587 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -23,14 +23,14 @@ module AvatarsHelper def assignee_avatar(user, options={}) return '' unless user - options.merge!(:title => l(:field_assigned_to) + ": " + user.name) + options[:title] = l(:field_assigned_to) + ": " + user.name avatar(user, options).to_s.html_safe end def author_avatar(user, options={}) return '' unless user - options.merge!(:title => l(:field_author) + ": " + user.name) + options[:title] = l(:field_author) + ": " + user.name avatar(user, options).to_s.html_safe end @@ -38,7 +38,7 @@ module AvatarsHelper # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>') def avatar(user, options = { }) if Setting.gravatar_enabled? - options.merge!(:default => Setting.gravatar_default) + options[:default] = Setting.gravatar_default options[:class] = GravatarHelper::DEFAULT_OPTIONS[:class] + " " + options[:class] if options[:class] email = nil if user.respond_to?(:mail) diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index be908562b..1e0c1b07e 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -190,7 +190,7 @@ module CustomFieldsHelper api.array :custom_fields do custom_values.each do |custom_value| attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name} - attrs.merge!(:multiple => true) if custom_value.custom_field.multiple? + attrs[:multiple] = true if custom_value.custom_field.multiple? api.custom_field attrs do if custom_value.value.is_a?(Array) api.array :value do diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb index 21ee21d49..5cfe93a86 100644 --- a/app/helpers/workflows_helper.rb +++ b/app/helpers/workflows_helper.rb @@ -35,7 +35,7 @@ module WorkflowsHelper end all_tag_options = {:value => 'all', :selected => (selected == 'all')} if multiple - all_tag_options.merge!(:style => "display:none;") + all_tag_options[:style] = "display:none;" end option_tags << content_tag('option', l(:label_all), all_tag_options) option_tags << options_from_collection_for_select(objects, "id", "name", selected) diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index cfc0fb4be..7adbf45bc 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -187,7 +187,7 @@ class AuthSourceLdap < AuthSource } end unless ldap_user.blank? && ldap_password.blank? - options.merge!(:auth => {:method => :simple, :username => ldap_user, :password => ldap_password}) + options[:auth] = {:method => :simple, :username => ldap_user, :password => ldap_password} end Net::LDAP.new options end diff --git a/app/models/principal.rb b/app/models/principal.rb index 47fa62ba5..525693129 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -80,7 +80,7 @@ class Principal < ActiveRecord::Base if tokens.present? sql << ' OR (' sql << tokens.map.with_index do |token, index| - params.merge!(:"token_#{index}" => token) + params[:"token_#{index}"] = token "(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}))" end.join(' AND ') sql << ')' diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index 727e60c27..46b3bc048 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -84,7 +84,7 @@ module Redmine def permission(name, hash, options={}) @permissions ||= [] - options.merge!(:project_module => @project_module) + options[:project_module] = @project_module @permissions << Permission.new(name, hash, options) end diff --git a/test/functional/imports_controller_test.rb b/test/functional/imports_controller_test.rb index 17924f644..3da3f3016 100644 --- a/test/functional/imports_controller_test.rb +++ b/test/functional/imports_controller_test.rb @@ -405,7 +405,7 @@ class ImportsControllerTest < Redmine::ControllerTest def test_show_with_errors_should_show_unsaved_items import = generate_import_with_mapping - import.mapping.merge! 'subject' => 20 + import.mapping['subject'] = 20 import.run assert_not_equal 0, import.unsaved_items.count diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb index bd66a3dc1..1328c3bca 100644 --- a/test/unit/issue_import_test.rb +++ b/test/unit/issue_import_test.rb @@ -75,7 +75,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_mapping_with_fixed_tracker import = generate_import_with_mapping - import.mapping.merge!('tracker' => 'value:2') + import.mapping['tracker'] = 'value:2' import.save! issues = new_records(Issue, 3) { import.run } @@ -84,7 +84,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_mapping_with_mapped_tracker import = generate_import_with_mapping - import.mapping.merge!('tracker' => '13') + import.mapping['tracker'] = '13' import.save! issues = new_records(Issue, 3) { import.run } @@ -95,7 +95,7 @@ class IssueImportTest < ActiveSupport::TestCase Tracker.find_by_name('Feature request').update!(:name => 'Feature') import = generate_import_with_mapping - import.mapping.merge!('tracker' => '13') + import.mapping['tracker'] = '13' import.save! import.run @@ -106,7 +106,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_status_should_be_set import = generate_import_with_mapping - import.mapping.merge!('status' => '14') + import.mapping['status'] = '14' import.save! issues = new_records(Issue, 3) { import.run } @@ -115,7 +115,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_parent_should_be_set import = generate_import_with_mapping - import.mapping.merge!('parent_issue_id' => '5') + import.mapping['parent_issue_id'] = '5' import.save! issues = new_records(Issue, 3) { import.run } @@ -126,7 +126,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_import_utf8_with_bom import = generate_import_with_mapping('import_issues_utf8_with_bom.csv') - import.settings.merge!('encoding' => 'UTF-8') + import.settings['encoding'] = 'UTF-8' import.save issues = new_records(Issue,3) { import.run } @@ -275,7 +275,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_assignee_should_be_set import = generate_import_with_mapping - import.mapping.merge!('assigned_to' => '11') + import.mapping['assigned_to'] = '11' import.save! issues = new_records(Issue, 3) { import.run } @@ -285,7 +285,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_user_custom_field_should_be_set field = IssueCustomField.generate!(:field_format => 'user', :is_for_all => true, :trackers => Tracker.all) import = generate_import_with_mapping - import.mapping.merge!("cf_#{field.id}" => '11') + import.mapping["cf_#{field.id}"] = '11' import.save! issues = new_records(Issue, 3) { import.run } @@ -297,7 +297,7 @@ class IssueImportTest < ActiveSupport::TestCase field.tracker_ids = Tracker.all.ids field.save! import = generate_import_with_mapping - import.mapping.merge!("cf_1" => '8') + import.mapping["cf_1"] = '8' import.save! issues = new_records(Issue, 3) { import.run } @@ -312,7 +312,7 @@ class IssueImportTest < ActiveSupport::TestCase field.multiple = true field.save! import = generate_import_with_mapping - import.mapping.merge!("cf_1" => '15') + import.mapping["cf_1"] = '15' import.save! issues = new_records(Issue, 3) { import.run } @@ -323,7 +323,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_is_private_should_be_set_based_on_user_locale import = generate_import_with_mapping - import.mapping.merge!('is_private' => '6') + import.mapping['is_private'] = '6' import.save! issues = new_records(Issue, 3) { import.run } @@ -333,7 +333,7 @@ class IssueImportTest < ActiveSupport::TestCase def test_dates_should_be_parsed_using_date_format_setting field = IssueCustomField.generate!(:field_format => 'date', :is_for_all => true, :trackers => Tracker.all) import = generate_import_with_mapping('import_dates.csv') - import.settings.merge!('date_format' => Import::DATE_FORMATS[1]) + import.settings['date_format'] = Import::DATE_FORMATS[1] import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1', 'due_date' => '2', "cf_#{field.id}" => '3') import.save! @@ -345,7 +345,7 @@ class IssueImportTest < ActiveSupport::TestCase # Tests using other date formats import = generate_import_with_mapping('import_dates_ja.csv') - import.settings.merge!('date_format' => Import::DATE_FORMATS[3]) + import.settings['date_format'] = Import::DATE_FORMATS[3] import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1') import.save! @@ -377,7 +377,7 @@ class IssueImportTest < ActiveSupport::TestCase system_version.save! import = generate_import_with_mapping - import.mapping.merge!('fixed_version' => '9') + import.mapping['fixed_version'] = '9' import.save! issues = new_records(Issue, 3) { import.run } diff --git a/test/unit/time_entry_import_test.rb b/test/unit/time_entry_import_test.rb index 0d4a53940..26aa07b0c 100644 --- a/test/unit/time_entry_import_test.rb +++ b/test/unit/time_entry_import_test.rb @@ -87,7 +87,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase def test_maps_activity_to_column_value import = generate_import_with_mapping - import.mapping.merge!('activity' => '5') + import.mapping['activity'] = '5' import.save! # N.B. last row is not imported due to the usage of a disabled activity @@ -116,7 +116,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase overtime_cf = CustomField.find(10) import = generate_import_with_mapping - import.mapping.merge!('cf_10' => '6') + import.mapping['cf_10'] = '6' import.save! first, second, third, fourth = new_records(TimeEntry, 4) { import.run } @@ -142,7 +142,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase Role.find_by_name('Manager').add_permission! :log_time_for_other_users import = generate_import_with_mapping - import.mapping.merge!('user' => 'value:3') + import.mapping['user'] = 'value:3' import.save! first, second, third, fourth = new_records(TimeEntry, 4) { import.run } |