diff --git a/.rubocop.yml b/.rubocop.yml index 88264d046ae86f479d703c16a92d7a475f99fffb..4c6438f8b0d78da3612c41b15ef299162a082538 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -889,6 +889,10 @@ Lint/Loop: Metrics/BlockLength: Enabled: false +Performance/RedundantMerge: + Enabled: true + MaxKeyValuePairs: 1 + RSpec/LetSetup: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 29453cb49810a973d1d10ffebfd19df6cb57361a..ca80e9c3f205feadcde76f46ee9ac87e59df7017 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -51,12 +51,6 @@ Performance/RedundantMatch: - 'lib/gitlab/diff/highlight.rb' - 'lib/gitlab/diff/parser.rb' -# Offense count: 25 -# Cop supports --auto-correct. -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Enabled: false - # Offense count: 15 # Configuration parameters: CustomIncludeMethods. RSpec/EmptyExampleGroup: diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb index ff787fb4131480c8b958a39b82acc1d54b6c0bc6..8ad3851fb9a0c20fdead1004e2cdaab111e55cef 100644 --- a/app/helpers/sorting_helper.rb +++ b/app/helpers/sorting_helper.rb @@ -30,7 +30,7 @@ module SortingHelper } if current_controller?('admin/projects') - options.merge!(sort_value_largest_repo => sort_title_largest_repo) + options[sort_value_largest_repo] = sort_title_largest_repo end options diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index e07ae9d166087ce3ebd22b0c9bf2551a82e6243c..768baa80c01d894df2a045daf24a55e3e4f64132 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -235,7 +235,7 @@ module Issuable # DEPRECATED repository: project.hook_attrs.slice(:name, :url, :description, :homepage) } - hook_data.merge!(assignee: assignee.hook_attrs) if assignee + hook_data[:assignee] = assignee.hook_attrs if assignee hook_data end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index a0b8a63d6ab81e3dc67d050e81960126acef7eb7..ea784f77015ae3468d96cd7ada039b324ac2bdfc 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -527,7 +527,7 @@ class MergeRequest < ActiveRecord::Base } if diff_head_commit - attrs.merge!(last_commit: diff_head_commit.hook_attrs) + attrs[:last_commit] = diff_head_commit.hook_attrs end attributes.merge!(attrs) diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb index a963d27a37652e491cd712115364babbc52f942d..f623bf9851b63a6ab609815e66ddf5c13da0d5f2 100644 --- a/app/models/project_services/pushover_service.rb +++ b/app/models/project_services/pushover_service.rb @@ -97,7 +97,7 @@ class PushoverService < Service # Sound parameter MUST NOT be sent to API if not selected if sound - pushover_data.merge!(sound: sound) + pushover_data[:sound] = sound end PushoverService.post('/messages.json', body: pushover_data) diff --git a/app/services/protected_branches/api_update_service.rb b/app/services/protected_branches/api_update_service.rb index 050cb3b738b6cc92993cd4ddafe0607391bff69a..bdb0e0cc8bf2cc4cee732e84c93764fcd94029ed 100644 --- a/app/services/protected_branches/api_update_service.rb +++ b/app/services/protected_branches/api_update_service.rb @@ -15,16 +15,16 @@ module ProtectedBranches case @developers_can_push when true - params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) + params[:push_access_levels_attributes] = [{ access_level: Gitlab::Access::DEVELOPER }] when false - params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) + params[:push_access_levels_attributes] = [{ access_level: Gitlab::Access::MASTER }] end case @developers_can_merge when true - params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) + params[:merge_access_levels_attributes] = [{ access_level: Gitlab::Access::DEVELOPER }] when false - params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) + params[:merge_access_levels_attributes] = [{ access_level: Gitlab::Access::MASTER }] end service = ProtectedBranches::UpdateService.new(@project, @current_user, @params) diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index a2bfa422c9d4572f2becdd5211119518fd7588d4..9b6dd013e3a4eec244dce901a446fddfa687c3c3 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -33,9 +33,7 @@ class SystemHooksService data.merge!(project_data(model)) if event == :rename || event == :transfer - data.merge!({ - old_path_with_namespace: model.old_path_with_namespace - }) + data[:old_path_with_namespace] = model.old_path_with_namespace end data diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 87ba72cf99190aeb9fd7f6b00c45a59308b23aca..71b4f8605a4df24a7bac2a365cc9268e6559caef 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -359,7 +359,7 @@ module SystemNoteService if noteable.kind_of?(Commit) note_options.merge!(noteable_type: 'Commit', commit_id: noteable.id) else - note_options.merge!(noteable: noteable) + note_options[:noteable] = noteable end if noteable.is_a?(ExternalIssue) diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb index 79dde620265d7a2f51145f20a1b44731df13a9a3..3d9cedf5c2d649b5e7b2a1c2fceeb327fe780241 100644 --- a/features/steps/shared/issuable.rb +++ b/features/steps/shared/issuable.rb @@ -153,7 +153,7 @@ module SharedIssuable case type when :issue - attrs.merge!(project: project) + attrs[:project] = project when :merge_request attrs.merge!( source_project: project, diff --git a/lib/api/users.rb b/lib/api/users.rb index fbc179536912b77a6f66a2c6b2b75f270d61050b..94b2b6653d20f500a4d4e43eb554348360cd4cf5 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -172,7 +172,7 @@ module API end end - user_params.merge!(password_expires_at: Time.now) if user_params[:password].present? + user_params[:password_expires_at] = Time.now if user_params[:password].present? if user.update_attributes(user_params.except(:extern_uid, :provider)) present user, with: Entities::UserPublic diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index a631425b3cf5837c57dd758d09223e2fbbb285dd..a160869541a51248bb8e24fee7f6cb659a16913b 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -285,7 +285,7 @@ module Gitlab def fetch_resources(resource_type, *opts) return if imported?(resource_type) - opts.last.merge!(page: current_page(resource_type)) + opts.last[:page] = current_page(resource_type) client.public_send(resource_type, *opts) do |resources| yield resources diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb index f8b05d4e9bc197c6e85f97f767eb90c006177887..77a04507be105896e24737c6f8ad435584258697 100644 --- a/spec/finders/notes_finder_spec.rb +++ b/spec/finders/notes_finder_spec.rb @@ -111,7 +111,7 @@ describe NotesFinder do end it 'raises an exception for an invalid target_type' do - params.merge!(target_type: 'invalid') + params[:target_type] = 'invalid' expect { described_class.new(project, user, params).execute }.to raise_error('invalid target_type') end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index af515ad2e0e02be2dfb21151874bc4b52cca52ac..62f21049b0bf7936ad982e9585e90112f6855341 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -50,7 +50,7 @@ describe Projects::CreateService, '#execute', services: true do context 'error handling' do it 'handles invalid options' do - opts.merge!({ default_branch: 'master' } ) + opts[:default_branch] = 'master' expect(create_project(user, opts)).to eq(nil) end end @@ -67,7 +67,7 @@ describe Projects::CreateService, '#execute', services: true do context 'wiki_enabled false does not create wiki repository directory' do it do - opts.merge!(wiki_enabled: false) + opts[:wiki_enabled] = false project = create_project(user, opts) path = ProjectWiki.new(project, user).send(:path_to_repo)