Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-08-27 18:31:01 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2018-09-11 18:32:00 +0300
commit2039c8280db1646845c33d6c5a74e5f23ca6f4de (patch)
treee2b3cd3012d9711cda7c6afb962ae4228d59521a /app/services/boards
parent91c40973dc620430b173ea2df968587d2a708dff (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/boards')
-rw-r--r--app/services/boards/issues/list_service.rb12
-rw-r--r--app/services/boards/issues/move_service.rb6
-rw-r--r--app/services/boards/lists/destroy_service.rb2
-rw-r--r--app/services/boards/lists/move_service.rb4
4 files changed, 24 insertions, 0 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 0db1418b37a..4e352f2dc63 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -9,6 +9,7 @@ module Boards
fetch_issues.order_by_position_and_priority
end
+ # rubocop: disable CodeReuse/ActiveRecord
def metadata
keys = metadata_fields.keys
columns = metadata_fields.values_at(*keys).join(', ')
@@ -16,6 +17,7 @@ module Boards
Hash[keys.zip(results.flatten)]
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -24,6 +26,7 @@ module Boards
end
# We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
+ # rubocop: disable CodeReuse/ActiveRecord
def fetch_issues
strong_memoize(:fetch_issues) do
issues = IssuesFinder.new(current_user, filter_params).execute
@@ -31,6 +34,7 @@ module Boards
filter(issues).reorder(nil)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter(issues)
issues = without_board_labels(issues) unless list&.movable? || list&.closed?
@@ -72,24 +76,32 @@ module Boards
params[:include_subgroups] = board.group_board?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def board_label_ids
@board_label_ids ||= board.lists.movable.pluck(:label_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def without_board_labels(issues)
return issues unless board_label_ids.any?
issues.where.not('EXISTS (?)', issues_label_links.limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def issues_label_links
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id").where(label_id: board_label_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def with_list_label(issues)
issues.where('EXISTS (?)', LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 6fd8a23b2a1..7dd87034410 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -21,13 +21,17 @@ module Boards
moving_from_list != moving_to_list
end
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_from_list
@moving_from_list ||= board.lists.find_by(id: params[:from_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_to_list
@moving_to_list ||= board.lists.find_by(id: params[:to_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update(issue)
::Issues::UpdateService.new(issue.project, current_user, issue_params(issue)).execute(issue)
@@ -61,6 +65,7 @@ module Boards
[moving_to_list.label_id].compact
end
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_label_ids
label_ids =
if moving_to_list.movable?
@@ -73,6 +78,7 @@ module Boards
Array(label_ids).compact
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_between_ids
return unless params[:move_after_id] || params[:move_before_id]
diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb
index e12d4f46e19..609c430caed 100644
--- a/app/services/boards/lists/destroy_service.rb
+++ b/app/services/boards/lists/destroy_service.rb
@@ -18,10 +18,12 @@ module Boards
attr_reader :board
+ # rubocop: disable CodeReuse/ActiveRecord
def decrement_higher_lists(list)
board.lists.movable.where('position > ?', list.position)
.update_all('position = position - 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remove_list(list)
list.destroy
diff --git a/app/services/boards/lists/move_service.rb b/app/services/boards/lists/move_service.rb
index 27a36051662..93f81837d1a 100644
--- a/app/services/boards/lists/move_service.rb
+++ b/app/services/boards/lists/move_service.rb
@@ -34,17 +34,21 @@ module Boards
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def decrement_intermediate_lists
board.lists.movable.where('position > ?', old_position)
.where('position <= ?', new_position)
.update_all('position = position - 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def increment_intermediate_lists
board.lists.movable.where('position >= ?', new_position)
.where('position < ?', old_position)
.update_all('position = position + 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_list_position(list)
list.update_attribute(:position, new_position)