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. --- app/services/todo_service.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/services/todo_service.rb') diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 0df61ad3bce..4fe6c1ec986 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -41,6 +41,7 @@ class TodoService # collects the todo users before the todos themselves are deleted, then # updates the todo counts for those users. # + # rubocop: disable CodeReuse/ActiveRecord def destroy_target(target) todo_users = User.where(id: target.todos.pending.select(:user_id)).to_a @@ -48,6 +49,7 @@ class TodoService todo_users.each(&:update_todos_count_cache) end + # rubocop: enable CodeReuse/ActiveRecord # When we reassign an issue we should: # @@ -198,16 +200,21 @@ class TodoService create_todos(current_user, attributes) end + # rubocop: disable CodeReuse/ActiveRecord def todo_exist?(issuable, current_user) TodosFinder.new(current_user).execute.exists?(target: issuable) end + # rubocop: enable CodeReuse/ActiveRecord private + # rubocop: disable CodeReuse/ActiveRecord def todos_by_ids(ids, current_user) current_user.todos.where(id: Array(ids)) end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def update_todos_state(todos, current_user, state) # Only update those that are not really on that state todos = todos.where.not(state: state) @@ -216,6 +223,7 @@ class TodoService current_user.update_todos_count_cache todos_ids end + # rubocop: enable CodeReuse/ActiveRecord def create_todos(users, attributes) Array(users).map do |user| @@ -340,8 +348,10 @@ class TodoService end end + # rubocop: disable CodeReuse/ActiveRecord def pending_todos(user, criteria = {}) valid_keys = [:project_id, :target_id, :target_type, :commit_id] user.todos.pending.where(criteria.slice(*valid_keys)) end + # rubocop: enable CodeReuse/ActiveRecord end -- cgit v1.2.3