From 2039c8280db1646845c33d6c5a74e5f23ca6f4de Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 27 Aug 2018 17:31:01 +0200 Subject: Disable existing offenses for the CodeReuse cops This whitelists all existing offenses for the various CodeReuse cops, of which most are triggered by the CodeReuse/ActiveRecord cop. --- lib/gitlab/import/database_helpers.rb | 2 ++ lib/gitlab/import/merge_request_helpers.rb | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'lib/gitlab/import') diff --git a/lib/gitlab/import/database_helpers.rb b/lib/gitlab/import/database_helpers.rb index 80857061933..5b3f30d894a 100644 --- a/lib/gitlab/import/database_helpers.rb +++ b/lib/gitlab/import/database_helpers.rb @@ -8,6 +8,7 @@ module Gitlab # attributes - The attributes/columns to set. # relation - An ActiveRecord::Relation to use for finding the ID of the row # when using MySQL. + # rubocop: disable CodeReuse/ActiveRecord def insert_and_return_id(attributes, relation) # We use bulk_insert here so we can bypass any queries executed by # callbacks or validation rules, as doing this wouldn't scale when @@ -20,6 +21,7 @@ module Gitlab result.first || relation.where(iid: attributes[:iid]).limit(1).pluck(:id).first end + # rubocop: enable CodeReuse/ActiveRecord end end end diff --git a/lib/gitlab/import/merge_request_helpers.rb b/lib/gitlab/import/merge_request_helpers.rb index 8ba70700dc1..97dc1a987c4 100644 --- a/lib/gitlab/import/merge_request_helpers.rb +++ b/lib/gitlab/import/merge_request_helpers.rb @@ -5,6 +5,7 @@ module Gitlab module MergeRequestHelpers include DatabaseHelpers + # rubocop: disable CodeReuse/ActiveRecord def create_merge_request_without_hooks(project, attributes, iid) # This work must be wrapped in a transaction as otherwise we can leave # behind incomplete data in the event of an error. This can then lead @@ -39,7 +40,9 @@ module Gitlab # existing row. [project.merge_requests.find_by(iid: iid), true] end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def insert_or_replace_git_data(merge_request, source_branch_sha, target_branch_sha, already_exists = false) # These fields are set so we can create the correct merge request # diffs. @@ -65,6 +68,7 @@ module Gitlab diff.save diff.save_git_content end + # rubocop: enable CodeReuse/ActiveRecord end end end -- cgit v1.2.3