diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-08-27 18:31:01 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-09-11 18:32:00 +0300 |
commit | 2039c8280db1646845c33d6c5a74e5f23ca6f4de (patch) | |
tree | e2b3cd3012d9711cda7c6afb962ae4228d59521a /app/services/labels/transfer_service.rb | |
parent | 91c40973dc620430b173ea2df968587d2a708dff (diff) |
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.
Diffstat (limited to 'app/services/labels/transfer_service.rb')
-rw-r--r-- | app/services/labels/transfer_service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb index 1bd8d9fc325..aec0282b31b 100644 --- a/app/services/labels/transfer_service.rb +++ b/app/services/labels/transfer_service.rb @@ -32,6 +32,7 @@ module Labels attr_reader :current_user, :old_group, :project + # rubocop: disable CodeReuse/ActiveRecord def labels_to_transfer label_ids = [] label_ids << group_labels_applied_to_issues.select(:id) @@ -41,7 +42,9 @@ module Labels Label.where("labels.id IN (#{union.to_sql})").reorder(nil).uniq # rubocop:disable GitlabSecurity/SqlInjection end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def group_labels_applied_to_issues Label.joins(:issues) .where( @@ -49,7 +52,9 @@ module Labels labels: { type: 'GroupLabel', group_id: old_group.id } ) end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def group_labels_applied_to_merge_requests Label.joins(:merge_requests) .where( @@ -57,6 +62,7 @@ module Labels labels: { type: 'GroupLabel', group_id: old_group.id } ) end + # rubocop: enable CodeReuse/ActiveRecord def find_or_create_label!(label) params = label.attributes.slice('title', 'description', 'color') @@ -65,6 +71,7 @@ module Labels new_label.id end + # rubocop: disable CodeReuse/ActiveRecord def update_label_links(labels, old_label_id:, new_label_id:) # use 'labels' relation to get label_link ids only of issues/MRs # in the project being transferred. @@ -76,10 +83,13 @@ module Labels LabelLink.where(id: link_ids, label_id: old_label_id) .update_all(label_id: new_label_id) end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def update_label_priorities(old_label_id:, new_label_id:) LabelPriority.where(project_id: project.id, label_id: old_label_id) .update_all(label_id: new_label_id) end + # rubocop: enable CodeReuse/ActiveRecord end end |