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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e4821b05
Commit
e4821b05
authored
Apr 01, 2021
by
Shubham Kumar
Committed by
Mayra Cabrera
Apr 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolves rubocop offense Rails/WhereNot
Fixes auto correct rubocop offenses
parent
8d8fc7dd
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
27 additions
and
28 deletions
+27
-28
.rubocop_todo.yml
.rubocop_todo.yml
+0
-5
app/finders/ci/pipelines_finder.rb
app/finders/ci/pipelines_finder.rb
+1
-1
app/models/ci/build.rb
app/models/ci/build.rb
+1
-2
app/models/ci/stage.rb
app/models/ci/stage.rb
+1
-1
app/models/clusters/clusters_hierarchy.rb
app/models/clusters/clusters_hierarchy.rb
+1
-1
app/models/environment.rb
app/models/environment.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/services/todos/destroy/base_service.rb
app/services/todos/destroy/base_service.rb
+1
-1
app/services/todos/destroy/private_features_service.rb
app/services/todos/destroy/private_features_service.rb
+1
-1
changelogs/unreleased/pl-rubocop-todo-where-not.yml
changelogs/unreleased/pl-rubocop-todo-where-not.yml
+5
-0
db/post_migrate/20200406102120_backfill_deployment_clusters_from_deployments.rb
...06102120_backfill_deployment_clusters_from_deployments.rb
+1
-1
db/post_migrate/20200811130433_create_missing_vulnerabilities_issue_links.rb
...00811130433_create_missing_vulnerabilities_issue_links.rb
+2
-2
ee/app/models/elastic/reindexing_task.rb
ee/app/models/elastic/reindexing_task.rb
+1
-1
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+1
-1
ee/spec/migrations/nullify_feature_flag_plaintext_tokens_spec.rb
.../migrations/nullify_feature_flag_plaintext_tokens_spec.rb
+1
-1
ee/spec/models/ee/description_version_spec.rb
ee/spec/models/ee/description_version_spec.rb
+1
-1
lib/gitlab/background_migration/populate_merge_request_assignees_table.rb
...round_migration/populate_merge_request_assignees_table.rb
+1
-1
lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb
...round_migration/wrongfully_confirmed_email_unconfirmer.rb
+1
-1
lib/gitlab/import_export/uploads_manager.rb
lib/gitlab/import_export/uploads_manager.rb
+1
-1
spec/lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start_spec.rb
...ics/cycle_analytics/stage_events/code_stage_start_spec.rb
+1
-1
spec/migrations/clean_up_noteable_id_for_notes_on_commits_spec.rb
...rations/clean_up_noteable_id_for_notes_on_commits_spec.rb
+1
-1
spec/migrations/migrate_bot_type_to_user_type_spec.rb
spec/migrations/migrate_bot_type_to_user_type_spec.rb
+1
-1
No files found.
.rubocop_todo.yml
View file @
e4821b05
...
...
@@ -640,11 +640,6 @@ Rails/WhereEquals:
Rails/WhereExists
:
Enabled
:
false
# Offense count: 21
# Cop supports --auto-correct.
Rails/WhereNot
:
Enabled
:
false
# Offense count: 8
# Cop supports --auto-correct.
Security/YAMLLoad
:
...
...
app/finders/ci/pipelines_finder.rb
View file @
e4821b05
...
...
@@ -131,7 +131,7 @@ module Ci
def
by_yaml_errors
(
items
)
case
Gitlab
::
Utils
.
to_boolean
(
params
[
:yaml_errors
])
when
true
items
.
where
(
"yaml_errors IS NOT NULL"
)
items
.
where
.
not
(
yaml_errors:
nil
)
when
false
items
.
where
(
"yaml_errors IS NULL"
)
else
...
...
app/models/ci/build.rb
View file @
e4821b05
...
...
@@ -93,8 +93,7 @@ module Ci
validates
:ref
,
presence:
true
scope
:not_interruptible
,
->
do
joins
(
:metadata
).
where
(
'ci_builds_metadata.id NOT IN (?)'
,
Ci
::
BuildMetadata
.
scoped_build
.
with_interruptible
.
select
(
:id
))
joins
(
:metadata
).
where
.
not
(
'ci_builds_metadata.id'
=>
Ci
::
BuildMetadata
.
scoped_build
.
with_interruptible
.
select
(
:id
))
end
scope
:unstarted
,
->
{
where
(
runner_id:
nil
)
}
...
...
app/models/ci/stage.rb
View file @
e4821b05
...
...
@@ -44,7 +44,7 @@ module Ci
next
if
position
.
present?
self
.
position
=
statuses
.
select
(
:stage_idx
)
.
where
(
'stage_idx IS NOT NULL'
)
.
where
.
not
(
stage_idx:
nil
)
.
group
(
:stage_idx
)
.
order
(
'COUNT(*) DESC'
)
.
first
&
.
stage_idx
.
to_i
...
...
app/models/clusters/clusters_hierarchy.rb
View file @
e4821b05
...
...
@@ -16,7 +16,7 @@ module Clusters
model
.
unscoped
.
where
(
'clusters.id IS NOT NULL'
)
.
where
.
not
(
'clusters.id'
=>
nil
)
.
with
.
recursive
(
cte
.
to_arel
)
.
from
(
cte_alias
)
...
...
app/models/environment.rb
View file @
e4821b05
...
...
@@ -86,7 +86,7 @@ class Environment < ApplicationRecord
end
scope
:for_project
,
->
(
project
)
{
where
(
project_id:
project
)
}
scope
:for_tier
,
->
(
tier
)
{
where
(
tier:
tier
).
where
(
'tier IS NOT NULL'
)
}
scope
:for_tier
,
->
(
tier
)
{
where
(
tier:
tier
).
where
.
not
(
tier:
nil
)
}
scope
:with_deployment
,
->
(
sha
)
{
where
(
'EXISTS (?)'
,
Deployment
.
select
(
1
).
where
(
'deployments.environment_id = environments.id'
).
where
(
sha:
sha
))
}
scope
:unfoldered
,
->
{
where
(
environment_type:
nil
)
}
scope
:with_rank
,
->
do
...
...
app/models/project.rb
View file @
e4821b05
...
...
@@ -519,7 +519,7 @@ class Project < ApplicationRecord
scope
:with_packages
,
->
{
joins
(
:packages
)
}
scope
:in_namespace
,
->
(
namespace_ids
)
{
where
(
namespace_id:
namespace_ids
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
'namespace_id != ?'
,
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
.
not
(
namespace_id:
user
.
namespace_id
)
}
scope
:starred_by
,
->
(
user
)
{
joins
(
:users_star_projects
).
where
(
'users_star_projects.user_id'
:
user
.
id
)
}
scope
:visible_to_user
,
->
(
user
)
{
where
(
id:
user
.
authorized_projects
.
select
(
:id
).
reorder
(
nil
))
}
scope
:visible_to_user_and_access_level
,
->
(
user
,
access_level
)
{
where
(
id:
user
.
authorized_projects
.
where
(
'project_authorizations.access_level >= ?'
,
access_level
).
select
(
:id
).
reorder
(
nil
))
}
...
...
app/models/user.rb
View file @
e4821b05
...
...
@@ -1041,7 +1041,7 @@ class User < ApplicationRecord
[
Project
.
where
(
namespace:
namespace
),
Project
.
joins
(
:project_authorizations
)
.
where
(
"projects.namespace_id <> ?"
,
namespace
.
id
)
.
where
.
not
(
'projects.namespace_id'
=>
namespace
.
id
)
.
where
(
project_authorizations:
{
user_id:
id
,
access_level:
Gitlab
::
Access
::
OWNER
})
],
remove_duplicates:
false
...
...
app/services/todos/destroy/base_service.rb
View file @
e4821b05
...
...
@@ -13,7 +13,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
def
without_authorized
(
items
)
items
.
where
(
'todos.user_id NOT IN (?)'
,
authorized_users
)
items
.
where
.
not
(
'todos.user_id'
=>
authorized_users
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/services/todos/destroy/private_features_service.rb
View file @
e4821b05
...
...
@@ -36,7 +36,7 @@ module Todos
items
=
Todo
.
where
(
project_id:
project_id
)
items
=
items
.
where
(
user_id:
user_id
)
if
user_id
items
.
where
(
'user_id NOT IN (?)'
,
authorized_users
)
items
.
where
.
not
(
user_id:
authorized_users
)
.
where
(
target_type:
target_types
)
.
delete_all
end
...
...
changelogs/unreleased/pl-rubocop-todo-where-not.yml
0 → 100644
View file @
e4821b05
---
title
:
Resolves rubocop offenses Rails/WhereNot
merge_request
:
58062
author
:
Shubham Kumar (@imskr)
type
:
fixed
db/post_migrate/20200406102120_backfill_deployment_clusters_from_deployments.rb
View file @
e4821b05
...
...
@@ -17,7 +17,7 @@ class BackfillDeploymentClustersFromDeployments < ActiveRecord::Migration[6.0]
class
Deployment
<
ActiveRecord
::
Base
include
EachBatch
default_scope
{
where
(
'cluster_id IS NOT NULL'
)
}
# rubocop:disable Cop/DefaultScope
default_scope
{
where
.
not
(
cluster_id:
nil
)
}
# rubocop:disable Cop/DefaultScope
self
.
table_name
=
'deployments'
end
...
...
db/post_migrate/20200811130433_create_missing_vulnerabilities_issue_links.rb
View file @
e4821b05
...
...
@@ -18,11 +18,11 @@ class CreateMissingVulnerabilitiesIssueLinks < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def
up
VulnerabilitiesFeedback
.
where
(
'issue_id IS NOT NULL'
).
each_batch
do
|
relation
|
VulnerabilitiesFeedback
.
where
.
not
(
issue_id:
nil
).
each_batch
do
|
relation
|
timestamp
=
Time
.
now
issue_links
=
relation
.
joins
(
"JOIN vulnerability_occurrences vo ON vo.project_id = vulnerability_feedback.project_id AND vo.report_type = vulnerability_feedback.category AND encode(vo.project_fingerprint, 'hex') = vulnerability_feedback.project_fingerprint"
)
.
where
(
'vo.vulnerability_id IS NOT NULL'
)
.
where
.
not
(
'vo.vulnerability_id'
=>
nil
)
.
pluck
(
:vulnerability_id
,
:issue_id
)
.
map
do
|
v_id
,
i_id
|
{
...
...
ee/app/models/elastic/reindexing_task.rb
View file @
e4821b05
...
...
@@ -18,7 +18,7 @@ class Elastic::ReindexingTask < ApplicationRecord
original_index_deleted:
12
}
scope
:old_indices_scheduled_for_deletion
,
->
{
where
(
state: :success
).
where
(
'delete_original_index_at IS NOT NULL'
)
}
scope
:old_indices_scheduled_for_deletion
,
->
{
where
(
state: :success
).
where
.
not
(
delete_original_index_at:
nil
)
}
scope
:old_indices_to_be_deleted
,
->
{
old_indices_scheduled_for_deletion
.
where
(
'delete_original_index_at < NOW()'
)
}
before_save
:set_in_progress_flag
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
e4821b05
...
...
@@ -610,7 +610,7 @@ module EE
::
ApprovalMergeRequestRule
.
code_owner
.
joins
(
:merge_request
)
.
where
(
"section != ?"
,
::
Gitlab
::
CodeOwners
::
Entry
::
DEFAULT_SECTION
)
.
where
.
not
(
section:
::
Gitlab
::
CodeOwners
::
Entry
::
DEFAULT_SECTION
)
.
where
(
time_period
),
'merge_requests.target_project_id'
,
start:
project_minimum_id
,
...
...
ee/spec/migrations/nullify_feature_flag_plaintext_tokens_spec.rb
View file @
e4821b05
...
...
@@ -35,7 +35,7 @@ RSpec.describe NullifyFeatureFlagPlaintextTokens do
}
migration
.
after
->
{
expect
(
feature_flags_clients
.
where
(
'token IS NOT NULL'
).
count
).
to
eq
(
0
)
expect
(
feature_flags_clients
.
where
.
not
(
token:
nil
).
count
).
to
eq
(
0
)
feature_flag1
.
reload
expect
(
feature_flag1
.
token
).
to
be_nil
...
...
ee/spec/models/ee/description_version_spec.rb
View file @
e4821b05
...
...
@@ -49,7 +49,7 @@ RSpec.describe DescriptionVersion do
def
deleted_count
DescriptionVersion
.
where
(
'issue_id = ? or epic_id = ? or merge_request_id = ?'
,
issue
.
id
,
epic
.
id
,
merge_request
.
id
)
.
where
(
'deleted_at IS NOT NULL'
)
.
where
.
not
(
deleted_at:
nil
)
.
count
end
...
...
lib/gitlab/background_migration/populate_merge_request_assignees_table.rb
View file @
e4821b05
...
...
@@ -11,7 +11,7 @@ module Gitlab
MergeRequest
.
where
(
merge_request_assignees_not_exists_clause
)
.
where
(
id:
from_id
..
to_id
)
.
where
(
'assignee_id IS NOT NULL'
)
.
where
.
not
(
assignee_id:
nil
)
.
select
(
:id
,
:assignee_id
)
.
to_sql
...
...
lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb
View file @
e4821b05
...
...
@@ -27,7 +27,7 @@ module Gitlab
joins
(
:user
)
.
merge
(
UserModel
.
active
)
.
where
(
id:
(
start_id
..
stop_id
))
.
where
(
'emails.confirmed_at IS NOT NULL'
)
.
where
.
not
(
'emails.confirmed_at'
=>
nil
)
.
where
(
'emails.confirmed_at = users.confirmed_at'
)
.
where
(
'emails.email <> users.email'
)
.
where
(
'NOT EXISTS (SELECT 1 FROM user_synced_attributes_metadata WHERE user_id=users.id AND email_synced IS true)'
)
...
...
lib/gitlab/import_export/uploads_manager.rb
View file @
e4821b05
...
...
@@ -76,7 +76,7 @@ module Gitlab
def
project_uploads_except_avatar
(
avatar_path
)
return
@project
.
uploads
unless
avatar_path
@project
.
uploads
.
where
(
"path != ?"
,
avatar_path
)
@project
.
uploads
.
where
.
not
(
path:
avatar_path
)
end
def
download_and_copy
(
upload
)
...
...
spec/lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start_spec.rb
View file @
e4821b05
...
...
@@ -15,7 +15,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::StageEvents::CodeStageStart do
other_merge_request
=
create
(
:merge_request
,
source_project:
project
,
source_branch:
'a'
,
target_branch:
'master'
)
records
=
subject
.
apply_query_customization
(
MergeRequest
.
all
).
where
(
'merge_requests_closing_issues.issue_id IS NOT NULL'
)
records
=
subject
.
apply_query_customization
(
MergeRequest
.
all
).
where
.
not
(
'merge_requests_closing_issues.issue_id'
=>
nil
)
expect
(
records
).
to
eq
([
merge_request
])
expect
(
records
).
not_to
include
(
other_merge_request
)
end
...
...
spec/migrations/clean_up_noteable_id_for_notes_on_commits_spec.rb
View file @
e4821b05
...
...
@@ -25,7 +25,7 @@ RSpec.describe CleanUpNoteableIdForNotesOnCommits do
end
def
dirty_notes_on_commits
notes
.
where
(
noteable_type:
'Commit'
).
where
(
'noteable_id IS NOT NULL'
)
notes
.
where
(
noteable_type:
'Commit'
).
where
.
not
(
noteable_id:
nil
)
end
def
other_notes
...
...
spec/migrations/migrate_bot_type_to_user_type_spec.rb
View file @
e4821b05
...
...
@@ -15,6 +15,6 @@ RSpec.describe MigrateBotTypeToUserType, :migration do
migrate!
expect
(
users
.
where
(
'user_type IS NOT NULL'
).
map
(
&
:user_type
)).
to
match_array
([
1
,
2
,
3
])
expect
(
users
.
where
.
not
(
user_type:
nil
).
map
(
&
:user_type
)).
to
match_array
([
1
,
2
,
3
])
end
end
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