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/quick_actions | |
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/quick_actions')
-rw-r--r-- | app/services/quick_actions/interpret_service.rb | 12 | ||||
-rw-r--r-- | app/services/quick_actions/target_service.rb | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb index be9d1e48435..02d68c3add3 100644 --- a/app/services/quick_actions/interpret_service.rb +++ b/app/services/quick_actions/interpret_service.rb @@ -111,10 +111,12 @@ module QuickActions end desc 'Assign' + # rubocop: disable CodeReuse/ActiveRecord explanation do |users| users = issuable.allows_multiple_assignees? ? users : users.take(1) "Assigns #{users.map(&:to_reference).to_sentence}." end + # rubocop: enable CodeReuse/ActiveRecord params do issuable.allows_multiple_assignees? ? '@user1 @user2' : '@user' end @@ -124,6 +126,7 @@ module QuickActions parse_params do |assignee_param| extract_users(assignee_param) end + # rubocop: disable CodeReuse/ActiveRecord command :assign do |users| next if users.empty? @@ -134,6 +137,7 @@ module QuickActions [users.first.id] end end + # rubocop: enable CodeReuse/ActiveRecord desc do if issuable.allows_multiple_assignees? @@ -160,6 +164,7 @@ module QuickActions # When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed extract_users(unassign_param) if issuable.allows_multiple_assignees? end + # rubocop: disable CodeReuse/ActiveRecord command :unassign do |users = nil| @updates[:assignee_ids] = if users&.any? @@ -168,6 +173,7 @@ module QuickActions [] end end + # rubocop: enable CodeReuse/ActiveRecord desc 'Set milestone' explanation do |milestone| @@ -546,6 +552,7 @@ module QuickActions current_user.can?(:"update_#{issuable.to_ability_name}", issuable) && issuable.project.boards.count == 1 end + # rubocop: disable CodeReuse/ActiveRecord command :board_move do |target_list_name| label_ids = find_label_ids(target_list_name) @@ -560,6 +567,7 @@ module QuickActions @updates[:add_label_ids] = [label_id] end end + # rubocop: enable CodeReuse/ActiveRecord desc 'Mark this issue as a duplicate of another issue' explanation do |duplicate_reference| @@ -625,6 +633,7 @@ module QuickActions @updates[:tag_message] = message end + # rubocop: disable CodeReuse/ActiveRecord def extract_users(params) return [] if params.nil? @@ -641,6 +650,7 @@ module QuickActions users end + # rubocop: enable CodeReuse/ActiveRecord def find_milestones(project, params = {}) MilestonesFinder.new(params.merge(project_ids: [project.id], group_ids: [project.group&.id])).execute @@ -677,6 +687,7 @@ module QuickActions end end + # rubocop: disable CodeReuse/ActiveRecord def extract_references(arg, type) ext = Gitlab::ReferenceExtractor.new(project, current_user) @@ -684,5 +695,6 @@ module QuickActions ext.references(type) end + # rubocop: enable CodeReuse/ActiveRecord end end diff --git a/app/services/quick_actions/target_service.rb b/app/services/quick_actions/target_service.rb index d8ba52c6e50..69464c3c1ae 100644 --- a/app/services/quick_actions/target_service.rb +++ b/app/services/quick_actions/target_service.rb @@ -15,13 +15,17 @@ module QuickActions private + # rubocop: disable CodeReuse/ActiveRecord def issue(type_id) IssuesFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.issues.build end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def merge_request(type_id) MergeRequestsFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.merge_requests.build end + # rubocop: enable CodeReuse/ActiveRecord def commit(type_id) project.commit(type_id) |