Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
9606dbbb
Commit
9606dbbb
authored
Aug 16, 2018
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitelist existing destroy_all offenses
This whitelists all existing places where we use "destroy_all".
parent
96ce2da7
Changes
32
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
41 additions
and
33 deletions
+41
-33
app/controllers/projects/pages_controller.rb
app/controllers/projects/pages_controller.rb
+1
-1
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+1
-1
app/models/concerns/fast_destroy_all.rb
app/models/concerns/fast_destroy_all.rb
+1
-1
app/models/lfs_object.rb
app/models/lfs_object.rb
+2
-0
app/models/user.rb
app/models/user.rb
+1
-1
app/services/labels/promote_service.rb
app/services/labels/promote_service.rb
+1
-1
app/services/milestones/promote_service.rb
app/services/milestones/promote_service.rb
+1
-1
app/services/projects/move_deploy_keys_projects_service.rb
app/services/projects/move_deploy_keys_projects_service.rb
+1
-1
app/services/projects/move_lfs_objects_projects_service.rb
app/services/projects/move_lfs_objects_projects_service.rb
+1
-1
app/services/projects/move_notification_settings_service.rb
app/services/projects/move_notification_settings_service.rb
+1
-1
app/services/projects/move_project_group_links_service.rb
app/services/projects/move_project_group_links_service.rb
+1
-1
app/services/projects/move_project_members_service.rb
app/services/projects/move_project_members_service.rb
+1
-1
app/services/protected_branches/legacy_api_update_service.rb
app/services/protected_branches/legacy_api_update_service.rb
+2
-2
app/workers/remove_expired_group_links_worker.rb
app/workers/remove_expired_group_links_worker.rb
+1
-1
app/workers/remove_old_web_hook_logs_worker.rb
app/workers/remove_old_web_hook_logs_worker.rb
+2
-0
db/migrate/20160712171823_remove_award_emojis_with_no_user.rb
...igrate/20160712171823_remove_award_emojis_with_no_user.rb
+1
-1
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+1
-1
spec/controllers/omniauth_callbacks_controller_spec.rb
spec/controllers/omniauth_callbacks_controller_spec.rb
+1
-1
spec/controllers/projects/releases_controller_spec.rb
spec/controllers/projects/releases_controller_spec.rb
+1
-1
spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
...nd_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
+1
-1
spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
...ons/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
+1
-1
spec/models/fork_network_member_spec.rb
spec/models/fork_network_member_spec.rb
+1
-1
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+2
-2
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
spec/models/project_group_link_spec.rb
spec/models/project_group_link_spec.rb
+1
-1
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+1
-1
spec/rubocop/cop/destroy_all_spec.rb
spec/rubocop/cop/destroy_all_spec.rb
+3
-3
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+2
-0
spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb
...es/merge_requests/delete_non_latest_diffs_service_spec.rb
+2
-0
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+1
-1
spec/support/shared_examples/fast_destroy_all.rb
spec/support/shared_examples/fast_destroy_all.rb
+2
-2
spec/workers/repository_check/single_repository_worker_spec.rb
...workers/repository_check/single_repository_worker_spec.rb
+1
-1
No files found.
app/controllers/projects/pages_controller.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/models/concerns/awardable.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
app/models/concerns/fast_destroy_all.rb
View file @
9606dbbb
...
...
@@ -34,7 +34,7 @@ module FastDestroyAll
included
do
before_destroy
do
raise
ForbiddenActionError
,
'`destroy` and `destroy_all` are forb
bi
den. Please use `fast_destroy_all`'
raise
ForbiddenActionError
,
'`destroy` and `destroy_all` are forb
id
den. Please use `fast_destroy_all`'
end
end
...
...
app/models/lfs_object.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/models/user.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/labels/promote_service.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
app/services/milestones/promote_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/projects/move_deploy_keys_projects_service.rb
View file @
9606dbbb
...
...
@@ -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
app/services/projects/move_lfs_objects_projects_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/projects/move_notification_settings_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/projects/move_project_group_links_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/projects/move_project_members_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/services/protected_branches/legacy_api_update_service.rb
View file @
9606dbbb
...
...
@@ -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
...
...
app/workers/remove_expired_group_links_worker.rb
View file @
9606dbbb
...
...
@@ -5,6 +5,6 @@ class RemoveExpiredGroupLinksWorker
include
CronjobQueue
def
perform
ProjectGroupLink
.
expired
.
destroy_all
ProjectGroupLink
.
expired
.
destroy_all
# rubocop: disable DestroyAll
end
end
app/workers/remove_old_web_hook_logs_worker.rb
View file @
9606dbbb
...
...
@@ -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
db/migrate/20160712171823_remove_award_emojis_with_no_user.rb
View file @
9606dbbb
...
...
@@ -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
lib/gitlab/import_export/members_mapper.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/controllers/omniauth_callbacks_controller_spec.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
spec/controllers/projects/releases_controller_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/models/fork_network_member_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/models/hooks/system_hook_spec.rb
View file @
9606dbbb
...
...
@@ -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/
,
...
...
spec/models/merge_request_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/models/project_group_link_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/policies/group_policy_spec.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
spec/rubocop/cop/destroy_all_spec.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
spec/services/merge_requests/create_service_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
spec/services/todo_service_spec.rb
View file @
9606dbbb
...
...
@@ -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
...
...
spec/support/shared_examples/fast_destroy_all.rb
View file @
9606dbbb
...
...
@@ -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 forb
bi
den. Please use `fast_destroy_all`'
)
expect
{
subjects
.
destroy_all
}.
to
raise_error
(
'`destroy` and `destroy_all` are forb
biden. Please use `fast_destroy_all`'
)
expect
{
subjects
.
first
.
destroy
}.
to
raise_error
(
'`destroy` and `destroy_all` are forb
id
den. Please use `fast_destroy_all`'
)
expect
{
subjects
.
destroy_all
}.
to
raise_error
(
'`destroy` and `destroy_all` are forb
idden. Please use `fast_destroy_all`'
)
# rubocop: disable DestroyAll
expect
(
subjects
.
count
).
to
be
>
0
expect
(
external_data_counter
).
to
be
>
0
...
...
spec/workers/repository_check/single_repository_worker_spec.rb
View file @
9606dbbb
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment