Whitelist existing destroy_all offenses
This whitelists all existing places where we use "destroy_all".
This commit is contained in:
parent
96ce2da74e
commit
9606dbbb03
|
|
@ -11,7 +11,7 @@ class Projects::PagesController < Projects::ApplicationController
|
|||
|
||||
def destroy
|
||||
project.remove_pages
|
||||
project.pages_domains.destroy_all
|
||||
project.pages_domains.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ module Awardable
|
|||
end
|
||||
|
||||
def remove_award_emoji(name, current_user)
|
||||
award_emoji.where(name: name, user: current_user).destroy_all
|
||||
award_emoji.where(name: name, user: current_user).destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def toggle_award_emoji(emoji_name, current_user)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ module FastDestroyAll
|
|||
|
||||
included do
|
||||
before_destroy do
|
||||
raise ForbiddenActionError, '`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`'
|
||||
raise ForbiddenActionError, '`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ class LfsObject < ActiveRecord::Base
|
|||
[nil, LfsObjectUploader::Store::LOCAL].include?(self.file_store)
|
||||
end
|
||||
|
||||
# rubocop: disable DestroyAll
|
||||
def self.destroy_unreferenced
|
||||
joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id")
|
||||
.where(lfs_objects_projects: { id: nil })
|
||||
.destroy_all
|
||||
end
|
||||
# rubocop: enable DestroyAll
|
||||
|
||||
def self.calculate_oid(path)
|
||||
Digest::SHA256.file(path).hexdigest
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ class User < ActiveRecord::Base
|
|||
otp_grace_period_started_at: nil,
|
||||
otp_backup_codes: nil
|
||||
)
|
||||
self.u2f_registrations.destroy_all
|
||||
self.u2f_registrations.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ module Labels
|
|||
end
|
||||
|
||||
def update_project_labels(label_ids)
|
||||
Label.where(id: label_ids).destroy_all
|
||||
Label.where(id: label_ids).destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def clone_label_to_group_label(label)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ module Milestones
|
|||
end
|
||||
|
||||
def destroy_old_milestones(milestone)
|
||||
Milestone.where(id: milestone_ids_for_merge(milestone)).destroy_all
|
||||
Milestone.where(id: milestone_ids_for_merge(milestone)).destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def group_project_ids
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module Projects
|
|||
end
|
||||
|
||||
def remove_remaining_deploy_keys_projects
|
||||
source_project.deploy_keys_projects.destroy_all
|
||||
source_project.deploy_keys_projects.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module Projects
|
|||
end
|
||||
|
||||
def remove_remaining_lfs_objects_project
|
||||
source_project.lfs_objects_projects.destroy_all
|
||||
source_project.lfs_objects_projects.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def non_existent_lfs_objects_projects
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ module Projects
|
|||
|
||||
# Remove remaining notification settings from source_project
|
||||
def remove_remaining_notification_settings
|
||||
source_project.notification_settings.destroy_all
|
||||
source_project.notification_settings.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
# Get users of current notification_settings
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module Projects
|
|||
|
||||
# Remove remaining project group links from source_project
|
||||
def remove_remaining_project_group_links
|
||||
source_project.reload.project_group_links.destroy_all
|
||||
source_project.reload.project_group_links.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def group_links_in_target_project
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ module Projects
|
|||
|
||||
def remove_remaining_members
|
||||
# Remove remaining members and authorizations from source_project
|
||||
source_project.project_members.destroy_all
|
||||
source_project.project_members.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
def project_members_in_target_project
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ module ProtectedBranches
|
|||
|
||||
def delete_redundant_access_levels
|
||||
unless @developers_can_merge.nil?
|
||||
@protected_branch.merge_access_levels.destroy_all
|
||||
@protected_branch.merge_access_levels.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
unless @developers_can_push.nil?
|
||||
@protected_branch.push_access_levels.destroy_all
|
||||
@protected_branch.push_access_levels.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ class RemoveExpiredGroupLinksWorker
|
|||
include CronjobQueue
|
||||
|
||||
def perform
|
||||
ProjectGroupLink.expired.destroy_all
|
||||
ProjectGroupLink.expired.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ class RemoveOldWebHookLogsWorker
|
|||
|
||||
WEB_HOOK_LOG_LIFETIME = 2.days
|
||||
|
||||
# rubocop: disable DestroyAll
|
||||
def perform
|
||||
WebHookLog.destroy_all(['created_at < ?', Time.now - WEB_HOOK_LOG_LIFETIME])
|
||||
end
|
||||
# rubocop: enable DestroyAll
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ class RemoveAwardEmojisWithNoUser < ActiveRecord::Migration
|
|||
# disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all
|
||||
AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def ensure_default_member!
|
||||
@project.project_members.destroy_all
|
||||
@project.project_members.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
ProjectMember.create!(user: @user, access_level: ProjectMember::MAINTAINER, source_id: @project.id, importing: true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ describe OmniauthCallbacksController, type: :controller do
|
|||
end
|
||||
|
||||
it 'allows linking the disabled provider' do
|
||||
user.identities.destroy_all
|
||||
user.identities.destroy_all # rubocop: disable DestroyAll
|
||||
sign_in(user)
|
||||
|
||||
expect { post provider }.to change { user.reload.identities.count }.by(1)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ describe Projects::ReleasesController do
|
|||
describe 'GET #edit' do
|
||||
it 'initializes a new release' do
|
||||
tag_id = release.tag
|
||||
project.releases.destroy_all
|
||||
project.releases.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
get :edit, namespace_id: project.namespace, project_id: project, tag_id: tag_id
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ describe Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys, :migration
|
|||
let!(:gpg_key) { create(:gpg_key, key: GpgHelpers::User3.public_key) }
|
||||
|
||||
before do
|
||||
GpgKeySubkey.destroy_all
|
||||
GpgKeySubkey.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
it 'generate the subkeys' do
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
|
|||
create(:gpg_key, id: 1, key: GpgHelpers::User1.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
||||
create(:gpg_key, id: 2, key: GpgHelpers::User3.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
||||
# Delete all subkeys so they can be recreated
|
||||
GpgKeySubkey.destroy_all
|
||||
GpgKeySubkey.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
it 'correctly schedules background migrations' do
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe ForkNetworkMember do
|
|||
let(:fork_network) { fork_network_member.fork_network }
|
||||
|
||||
it 'removes the fork network if it was the last member' do
|
||||
fork_network.fork_network_members.destroy_all
|
||||
fork_network.fork_network_members.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
expect(ForkNetwork.count).to eq(0)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ describe SystemHook do
|
|||
|
||||
it "project_destroy hook" do
|
||||
project.add_maintainer(user)
|
||||
project.project_members.destroy_all
|
||||
project.project_members.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
expect(WebMock).to have_requested(:post, system_hook.url).with(
|
||||
body: /user_remove_from_team/,
|
||||
|
|
@ -110,7 +110,7 @@ describe SystemHook do
|
|||
|
||||
it 'group member destroy hook' do
|
||||
group.add_maintainer(user)
|
||||
group.group_members.destroy_all
|
||||
group.group_members.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
expect(WebMock).to have_requested(:post, system_hook.url).with(
|
||||
body: /user_remove_from_group/,
|
||||
|
|
|
|||
|
|
@ -1764,7 +1764,7 @@ describe MergeRequest do
|
|||
|
||||
context 'with no discussions' do
|
||||
before do
|
||||
merge_request.notes.destroy_all
|
||||
merge_request.notes.destroy_all # rubocop: disable DestroyAll
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ describe ProjectGroupLink do
|
|||
project.project_group_links.create(group: group)
|
||||
group_users.each { |user| expect(user.authorized_projects).to include(project) }
|
||||
|
||||
project.project_group_links.destroy_all
|
||||
project.project_group_links.destroy_all # rubocop: disable DestroyAll
|
||||
group_users.each { |user| expect(user.authorized_projects).not_to include(project) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ describe GroupPolicy do
|
|||
nested_group.add_guest(developer)
|
||||
nested_group.add_guest(maintainer)
|
||||
|
||||
group.owners.destroy_all
|
||||
group.owners.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
group.add_guest(owner)
|
||||
nested_group.add_owner(owner)
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ describe RuboCop::Cop::DestroyAll do
|
|||
subject(:cop) { described_class.new }
|
||||
|
||||
it 'flags the use of destroy_all with a send receiver' do
|
||||
inspect_source('foo.destroy_all')
|
||||
inspect_source('foo.destroy_all # rubocop: disable DestroyAll')
|
||||
|
||||
expect(cop.offenses.size).to eq(1)
|
||||
end
|
||||
|
||||
it 'flags the use of destroy_all with a constant receiver' do
|
||||
inspect_source('User.destroy_all')
|
||||
inspect_source('User.destroy_all # rubocop: disable DestroyAll')
|
||||
|
||||
expect(cop.offenses.size).to eq(1)
|
||||
end
|
||||
|
|
@ -29,7 +29,7 @@ describe RuboCop::Cop::DestroyAll do
|
|||
it 'flags the use of destroy_all with a local variable receiver' do
|
||||
inspect_source(<<~RUBY)
|
||||
users = User.all
|
||||
users.destroy_all
|
||||
users.destroy_all # rubocop: disable DestroyAll
|
||||
RUBY
|
||||
|
||||
expect(cop.offenses.size).to eq(1)
|
||||
|
|
|
|||
|
|
@ -134,9 +134,11 @@ describe MergeRequests::CreateService do
|
|||
let!(:pipeline_3) { create(:ci_pipeline, project: project, ref: "other_branch", project_id: project.id) }
|
||||
|
||||
before do
|
||||
# rubocop: disable DestroyAll
|
||||
project.merge_requests
|
||||
.where(source_branch: opts[:source_branch], target_branch: opts[:target_branch])
|
||||
.destroy_all
|
||||
# rubocop: enable DestroyAll
|
||||
end
|
||||
|
||||
it 'sets head pipeline' do
|
||||
|
|
|
|||
|
|
@ -46,10 +46,12 @@ describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_
|
|||
end
|
||||
|
||||
it 'schedules no removal if there is no non-latest diffs' do
|
||||
# rubocop: disable DestroyAll
|
||||
merge_request
|
||||
.merge_request_diffs
|
||||
.where.not(id: merge_request.latest_merge_request_diff_id)
|
||||
.destroy_all
|
||||
# rubocop: enable DestroyAll
|
||||
|
||||
expect(DeleteDiffFilesWorker).not_to receive(:bulk_perform_in)
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ describe TodoService do
|
|||
end
|
||||
|
||||
it 'does not create a todo if unassigned' do
|
||||
issue.assignees.destroy_all
|
||||
issue.assignees.destroy_all # rubocop: disable DestroyAll
|
||||
|
||||
should_not_create_any_todo { service.reassigned_issue(issue, author) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ shared_examples_for 'fast destroyable' do
|
|||
expect(external_data_counter).to be > 0
|
||||
expect(subjects.count).to be > 0
|
||||
|
||||
expect { subjects.first.destroy }.to raise_error('`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`')
|
||||
expect { subjects.destroy_all }.to raise_error('`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`')
|
||||
expect { subjects.first.destroy }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`')
|
||||
expect { subjects.destroy_all }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`') # rubocop: disable DestroyAll
|
||||
|
||||
expect(subjects.count).to be > 0
|
||||
expect(external_data_counter).to be > 0
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
|
|||
|
||||
it 'skips when the project has no push events' do
|
||||
project = create(:project, :repository, :wiki_disabled)
|
||||
project.events.destroy_all
|
||||
project.events.destroy_all # rubocop: disable DestroyAll
|
||||
break_project(project)
|
||||
|
||||
expect(worker).not_to receive(:git_fsck)
|
||||
|
|
|
|||
Loading…
Reference in New Issue