diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-21 17:50:22 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:31:57 -0600 |
commit | 030baf70d25a666b660b0024f000586631ee3daf (patch) | |
tree | 20dbdbb674e9a4fd0ad6d82161e34fd26aaf37cd | |
parent | c5a49cc3c56283ae5f015c808327b1a29ca09ed9 (diff) | |
download | gitlab-ce-030baf70d25a666b660b0024f000586631ee3daf.tar.gz |
Enable Performance/RedundantMerge
-rw-r--r-- | .rubocop.yml | 4 | ||||
-rw-r--r-- | .rubocop_todo.yml | 6 | ||||
-rw-r--r-- | app/helpers/sorting_helper.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | app/models/project_services/pushover_service.rb | 2 | ||||
-rw-r--r-- | app/services/protected_branches/api_update_service.rb | 8 | ||||
-rw-r--r-- | app/services/system_hooks_service.rb | 4 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 2 | ||||
-rw-r--r-- | features/steps/shared/issuable.rb | 2 | ||||
-rw-r--r-- | lib/api/users.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 2 | ||||
-rw-r--r-- | spec/finders/notes_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/projects/create_service_spec.rb | 4 |
14 files changed, 20 insertions, 24 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 88264d046ae..4c6438f8b0d 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 29453cb4981..ca80e9c3f20 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 ff787fb4131..8ad3851fb9a 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 e07ae9d1660..768baa80c01 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 a0b8a63d6ab..ea784f77015 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 a963d27a376..f623bf9851b 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 050cb3b738b..bdb0e0cc8bf 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 a2bfa422c9d..9b6dd013e3a 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 87ba72cf991..71b4f8605a4 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 79dde620265..3d9cedf5c2d 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 fbc17953691..94b2b6653d2 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 a631425b3cf..a160869541a 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 f8b05d4e9bc..77a04507be1 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 af515ad2e0e..62f21049b0b 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) |