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
c58ce73c
Commit
c58ce73c
authored
Aug 05, 2020
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve Style/NumericPredicate Cop exceptions
- follow style guide
parent
422fa39a
Changes
52
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
67 additions
and
122 deletions
+67
-122
.rubocop.yml
.rubocop.yml
+5
-0
.rubocop_todo.yml
.rubocop_todo.yml
+0
-60
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+1
-1
app/controllers/concerns/paginated_collection.rb
app/controllers/concerns/paginated_collection.rb
+1
-1
app/helpers/graph_helper.rb
app/helpers/graph_helper.rb
+1
-1
app/helpers/timeboxes_helper.rb
app/helpers/timeboxes_helper.rb
+2
-2
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-3
app/models/ci/stage.rb
app/models/ci/stage.rb
+1
-1
app/models/concerns/update_project_statistics.rb
app/models/concerns/update_project_statistics.rb
+1
-1
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-1
app/models/milestone.rb
app/models/milestone.rb
+1
-1
app/models/network/graph.rb
app/models/network/graph.rb
+4
-4
app/models/postgresql/replication_slot.rb
app/models/postgresql/replication_slot.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/models/suggestion.rb
app/models/suggestion.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/serializers/merge_request_widget_entity.rb
app/serializers/merge_request_widget_entity.rb
+1
-1
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+1
-1
app/services/cohorts_service.rb
app/services/cohorts_service.rb
+1
-1
app/services/discussions/resolve_service.rb
app/services/discussions/resolve_service.rb
+1
-1
app/services/issues/reorder_service.rb
app/services/issues/reorder_service.rb
+1
-1
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-1
app/services/packages/nuget/metadata_extraction_service.rb
app/services/packages/nuget/metadata_extraction_service.rb
+1
-1
app/services/packages/nuget/search_service.rb
app/services/packages/nuget/search_service.rb
+2
-2
app/services/projects/auto_devops/disable_service.rb
app/services/projects/auto_devops/disable_service.rb
+1
-1
app/services/projects/update_pages_service.rb
app/services/projects/update_pages_service.rb
+1
-1
app/services/search_service.rb
app/services/search_service.rb
+1
-1
app/workers/admin_email_worker.rb
app/workers/admin_email_worker.rb
+1
-1
app/workers/gitlab/import/advance_stage.rb
app/workers/gitlab/import/advance_stage.rb
+1
-1
config/initializers/validate_puma.rb
config/initializers/validate_puma.rb
+1
-1
ee/app/controllers/security/projects_controller.rb
ee/app/controllers/security/projects_controller.rb
+1
-1
ee/app/graphql/mutations/instance_security_dashboard/remove_project.rb
...l/mutations/instance_security_dashboard/remove_project.rb
+1
-1
ee/app/helpers/ee/timeboxes_helper.rb
ee/app/helpers/ee/timeboxes_helper.rb
+1
-1
ee/app/models/ci/minutes/quota.rb
ee/app/models/ci/minutes/quota.rb
+4
-4
ee/app/models/ee/ci/runner.rb
ee/app/models/ee/ci/runner.rb
+1
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-1
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+1
-1
ee/app/models/license.rb
ee/app/models/license.rb
+2
-2
ee/app/models/namespace_statistics.rb
ee/app/models/namespace_statistics.rb
+1
-1
ee/app/services/ee/issues/base_service.rb
ee/app/services/ee/issues/base_service.rb
+1
-1
ee/app/services/ee/merge_requests/approval_service.rb
ee/app/services/ee/merge_requests/approval_service.rb
+1
-1
ee/app/services/ee/quick_actions/target_service.rb
ee/app/services/ee/quick_actions/target_service.rb
+1
-1
ee/app/services/elastic/indexing_control_service.rb
ee/app/services/elastic/indexing_control_service.rb
+1
-1
ee/app/services/geo/hashed_storage_migration_service.rb
ee/app/services/geo/hashed_storage_migration_service.rb
+1
-1
ee/app/services/geo/prune_event_log_service.rb
ee/app/services/geo/prune_event_log_service.rb
+1
-1
ee/app/services/security/waf_anomaly_summary_service.rb
ee/app/services/security/waf_anomaly_summary_service.rb
+1
-1
ee/app/services/update_build_minutes_service.rb
ee/app/services/update_build_minutes_service.rb
+1
-1
ee/app/workers/geo/container_repository_sync_dispatch_worker.rb
.../workers/geo/container_repository_sync_dispatch_worker.rb
+1
-1
ee/app/workers/geo/file_download_dispatch_worker.rb
ee/app/workers/geo/file_download_dispatch_worker.rb
+1
-1
ee/app/workers/geo/registry_sync_worker.rb
ee/app/workers/geo/registry_sync_worker.rb
+1
-1
ee/app/workers/geo/repository_shard_sync_worker.rb
ee/app/workers/geo/repository_shard_sync_worker.rb
+1
-1
ee/app/workers/geo/repository_verification/primary/shard_worker.rb
...rkers/geo/repository_verification/primary/shard_worker.rb
+2
-2
No files found.
.rubocop.yml
View file @
c58ce73c
...
...
@@ -443,6 +443,11 @@ RSpec/HaveGitlabHttpStatus:
Style/MultilineWhenThen
:
Enabled
:
false
# We use EnforcedStyle of comparison here due to it being better
# performing code as seen in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36221#note_375659681
Style/NumericPredicate
:
EnforcedStyle
:
comparison
Style/FloatDivision
:
Enabled
:
false
...
...
.rubocop_todo.yml
View file @
c58ce73c
...
...
@@ -922,66 +922,6 @@ Style/Next:
Style/NumericLiteralPrefix
:
Enabled
:
false
# Offense count: 130
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
# We use EnforcedStyle of comparison here due to it being better
# performing code as seen https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36221#note_375659681
Style/NumericPredicate
:
EnforcedStyle
:
comparison
Exclude
:
-
'
app/controllers/concerns/issuable_collections.rb'
-
'
app/controllers/concerns/paginated_collection.rb'
-
'
app/helpers/graph_helper.rb'
-
'
app/helpers/timeboxes_helper.rb'
-
'
app/models/ci/pipeline.rb'
-
'
app/models/ci/stage.rb'
-
'
app/models/concerns/update_project_statistics.rb'
-
'
app/models/merge_request_diff.rb'
-
'
app/models/milestone.rb'
-
'
app/models/network/graph.rb'
-
'
app/models/postgresql/replication_slot.rb'
-
'
app/models/project.rb'
-
'
app/models/suggestion.rb'
-
'
app/models/user.rb'
-
'
app/serializers/merge_request_widget_entity.rb'
-
'
app/services/boards/issues/move_service.rb'
-
'
app/services/cohorts_service.rb'
-
'
app/services/discussions/resolve_service.rb'
-
'
app/services/issues/reorder_service.rb'
-
'
app/services/notes/create_service.rb'
-
'
app/services/packages/nuget/metadata_extraction_service.rb'
-
'
app/services/packages/nuget/search_service.rb'
-
'
app/services/projects/auto_devops/disable_service.rb'
-
'
app/services/projects/update_pages_service.rb'
-
'
app/services/search_service.rb'
-
'
app/workers/admin_email_worker.rb'
-
'
app/workers/gitlab/import/advance_stage.rb'
-
'
config/initializers/validate_puma.rb'
-
'
ee/app/controllers/security/projects_controller.rb'
-
'
ee/app/graphql/mutations/instance_security_dashboard/remove_project.rb'
-
'
ee/app/helpers/ee/timeboxes_helper.rb'
-
'
ee/app/models/ci/minutes/quota.rb'
-
'
ee/app/models/ee/ci/runner.rb'
-
'
ee/app/models/geo_node_status.rb'
-
'
ee/app/models/license.rb'
-
'
ee/app/models/namespace_statistics.rb'
-
'
ee/app/services/ee/issues/base_service.rb'
-
'
ee/app/services/ee/merge_requests/approval_service.rb'
-
'
ee/app/services/ee/quick_actions/target_service.rb'
-
'
ee/app/services/elastic/indexing_control_service.rb'
-
'
ee/app/services/geo/hashed_storage_migration_service.rb'
-
'
ee/app/services/geo/prune_event_log_service.rb'
-
'
ee/app/services/security/waf_anomaly_summary_service.rb'
-
'
ee/app/services/update_build_minutes_service.rb'
-
'
ee/app/workers/geo/container_repository_sync_dispatch_worker.rb'
-
'
ee/app/workers/geo/file_download_dispatch_worker.rb'
-
'
ee/app/workers/geo/registry_sync_worker.rb'
-
'
ee/app/workers/geo/repository_shard_sync_worker.rb'
-
'
ee/app/workers/geo/repository_verification/primary/shard_worker.rb'
-
'
ee/app/models/ee/project.rb'
# Offense count: 117
# Cop supports --auto-correct.
Style/ParallelAssignment
:
...
...
app/controllers/concerns/issuable_collections.rb
View file @
c58ce73c
...
...
@@ -65,7 +65,7 @@ module IssuableCollections
def
page_count_for_relation
(
relation
,
row_count
)
limit
=
relation
.
limit_value
.
to_f
return
1
if
limit
.
zero?
return
1
if
limit
==
0
(
row_count
.
to_f
/
limit
).
ceil
end
...
...
app/controllers/concerns/paginated_collection.rb
View file @
c58ce73c
...
...
@@ -6,7 +6,7 @@ module PaginatedCollection
private
def
redirect_out_of_range
(
collection
,
total_pages
=
collection
.
total_pages
)
return
false
if
total_pages
.
zero?
return
false
if
total_pages
==
0
out_of_range
=
collection
.
current_page
>
total_pages
...
...
app/helpers/graph_helper.rb
View file @
c58ce73c
...
...
@@ -17,7 +17,7 @@ module GraphHelper
end
def
success_ratio
(
counts
)
return
100
if
counts
[
:failed
]
.
zero?
return
100
if
counts
[
:failed
]
==
0
ratio
=
(
counts
[
:success
].
to_f
/
(
counts
[
:success
]
+
counts
[
:failed
]))
*
100
ratio
.
to_i
...
...
app/helpers/timeboxes_helper.rb
View file @
c58ce73c
...
...
@@ -155,7 +155,7 @@ module TimeboxesHelper
opened
=
milestone
.
opened_issues_count
closed
=
milestone
.
closed_issues_count
return
_
(
"Issues"
)
if
total
.
zero?
return
_
(
"Issues"
)
if
total
==
0
content
=
[]
...
...
@@ -187,7 +187,7 @@ module TimeboxesHelper
def
milestone_releases_tooltip_text
(
milestone
)
count
=
milestone
.
releases
.
count
return
_
(
"Releases"
)
if
count
.
zero?
return
_
(
"Releases"
)
if
count
==
0
n_
(
"%{releases} release"
,
"%{releases} releases"
,
count
)
%
{
releases:
count
}
end
...
...
app/models/ci/pipeline.rb
View file @
c58ce73c
...
...
@@ -408,7 +408,7 @@ module Ci
def
legacy_stage
(
name
)
stage
=
Ci
::
LegacyStage
.
new
(
self
,
name:
name
)
stage
unless
stage
.
statuses_count
.
zero?
stage
unless
stage
.
statuses_count
==
0
end
def
ref_exists?
...
...
@@ -657,7 +657,7 @@ module Ci
end
def
has_warnings?
number_of_warnings
.
positive?
number_of_warnings
>
0
end
def
number_of_warnings
...
...
@@ -820,7 +820,7 @@ module Ci
return
unless
started_at
seconds
=
(
started_at
-
created_at
).
to_i
seconds
unless
seconds
.
zero?
seconds
unless
seconds
==
0
end
def
update_duration
...
...
app/models/ci/stage.rb
View file @
c58ce73c
...
...
@@ -113,7 +113,7 @@ module Ci
end
def
has_warnings?
number_of_warnings
.
positive?
number_of_warnings
>
0
end
def
number_of_warnings
...
...
app/models/concerns/update_project_statistics.rb
View file @
c58ce73c
...
...
@@ -75,7 +75,7 @@ module UpdateProjectStatistics
end
def
schedule_update_project_statistic
(
delta
)
return
if
delta
.
zero?
return
if
delta
==
0
return
if
project
.
nil?
run_after_commit
do
...
...
app/models/merge_request_diff.rb
View file @
c58ce73c
...
...
@@ -621,7 +621,7 @@ class MergeRequestDiff < ApplicationRecord
def
save_diffs
new_attributes
=
{}
if
compare
.
commits
.
size
.
zero
?
if
compare
.
commits
.
empty
?
new_attributes
[
:state
]
=
:empty
else
diff_collection
=
compare
.
diffs
(
Commit
.
max_diff_options
)
...
...
app/models/milestone.rb
View file @
c58ce73c
...
...
@@ -127,7 +127,7 @@ class Milestone < ApplicationRecord
end
def
can_be_closed?
active?
&&
issues
.
opened
.
count
.
zero?
active?
&&
issues
.
opened
.
count
==
0
end
def
author_id
...
...
app/models/network/graph.rb
View file @
c58ce73c
...
...
@@ -211,7 +211,7 @@ module Network
# Visit branching chains
leaves
.
each
do
|
l
|
parents
=
l
.
parents
(
@map
).
select
{
|
p
|
p
.
space
.
zero?
}
parents
=
l
.
parents
(
@map
).
select
{
|
p
|
p
.
space
==
0
}
parents
.
each
do
|
p
|
place_chain
(
p
,
l
.
time
)
end
...
...
@@ -266,14 +266,14 @@ module Network
def
take_left_leaves
(
raw_commit
)
commit
=
@map
[
raw_commit
.
id
]
leaves
=
[]
leaves
.
push
(
commit
)
if
commit
.
space
.
zero?
leaves
.
push
(
commit
)
if
commit
.
space
==
0
loop
do
return
leaves
if
commit
.
parents
(
@map
).
count
.
zero?
return
leaves
if
commit
.
parents
(
@map
).
count
==
0
commit
=
commit
.
parents
(
@map
).
first
return
leaves
unless
commit
.
space
.
zero?
return
leaves
unless
commit
.
space
==
0
leaves
.
push
(
commit
)
end
...
...
app/models/postgresql/replication_slot.rb
View file @
c58ce73c
...
...
@@ -33,7 +33,7 @@ module Postgresql
# If too many replicas are falling behind too much, the availability of a
# GitLab instance might suffer. To prevent this from happening we require
# at least 1 replica to have data recent enough.
if
sizes
.
any?
&&
too_great
.
positive?
if
sizes
.
any?
&&
too_great
>
0
(
sizes
.
length
-
too_great
)
<=
1
else
false
...
...
app/models/project.rb
View file @
c58ce73c
...
...
@@ -1120,7 +1120,7 @@ class Project < ApplicationRecord
limit
=
creator
.
projects_limit
error
=
if
limit
.
zero?
if
limit
==
0
_
(
'Personal project creation is not allowed. Please contact your administrator with questions'
)
else
_
(
'Your project limit is %{limit} projects! Please contact your administrator to increase it'
)
...
...
app/models/suggestion.rb
View file @
c58ce73c
...
...
@@ -61,7 +61,7 @@ class Suggestion < ApplicationRecord
end
def
single_line?
lines_above
.
zero?
&&
lines_below
.
zero?
lines_above
==
0
&&
lines_below
==
0
end
def
target_line
...
...
app/models/user.rb
View file @
c58ce73c
...
...
@@ -954,7 +954,7 @@ class User < ApplicationRecord
def
require_ssh_key?
count
=
Users
::
KeysCountService
.
new
(
self
).
count
count
.
zero?
&&
Gitlab
::
ProtocolAccess
.
allowed?
(
'ssh'
)
count
==
0
&&
Gitlab
::
ProtocolAccess
.
allowed?
(
'ssh'
)
end
# rubocop: enable CodeReuse/ServiceClass
...
...
app/serializers/merge_request_widget_entity.rb
View file @
c58ce73c
...
...
@@ -137,7 +137,7 @@ class MergeRequestWidgetEntity < Grape::Entity
merge_request
.
source_branch_exists?
&&
merge_request
.
source_project
&
.
uses_default_ci_config?
&&
!
merge_request
.
source_project
.
has_ci?
&&
merge_request
.
commits_count
.
positive?
&&
merge_request
.
commits_count
>
0
&&
can?
(
current_user
,
:read_build
,
merge_request
.
source_project
)
&&
can?
(
current_user
,
:create_pipeline
,
merge_request
.
source_project
)
end
...
...
app/services/boards/issues/move_service.rb
View file @
c58ce73c
...
...
@@ -130,7 +130,7 @@ module Boards
def
move_between_ids
(
move_params
)
ids
=
[
move_params
[
:move_after_id
],
move_params
[
:move_before_id
]]
.
map
(
&
:to_i
)
.
map
{
|
m
|
m
.
positive?
?
m
:
nil
}
.
map
{
|
m
|
m
>
0
?
m
:
nil
}
ids
.
any?
?
ids
:
nil
end
...
...
app/services/cohorts_service.rb
View file @
c58ce73c
...
...
@@ -63,7 +63,7 @@ class CohortsService
overall_total
=
month_totals
.
first
month_totals
.
map
do
|
total
|
{
total:
total
,
percentage:
total
.
zero?
?
0
:
100
*
total
/
overall_total
}
{
total:
total
,
percentage:
total
==
0
?
0
:
100
*
total
/
overall_total
}
end
end
...
...
app/services/discussions/resolve_service.rb
View file @
c58ce73c
...
...
@@ -56,7 +56,7 @@ module Discussions
def
process_auto_merge
return
unless
merge_request
return
unless
@resolved_count
.
positive?
return
unless
@resolved_count
>
0
return
unless
discussions_ready_to_merge?
AutoMergeProcessWorker
.
perform_async
(
merge_request
.
id
)
...
...
app/services/issues/reorder_service.rb
View file @
c58ce73c
...
...
@@ -40,7 +40,7 @@ module Issues
def
move_between_ids
ids
=
[
params
[
:move_after_id
],
params
[
:move_before_id
]]
.
map
(
&
:to_i
)
.
map
{
|
m
|
m
.
positive?
?
m
:
nil
}
.
map
{
|
m
|
m
>
0
?
m
:
nil
}
ids
.
any?
?
ids
:
nil
end
...
...
app/services/notes/create_service.rb
View file @
c58ce73c
...
...
@@ -72,7 +72,7 @@ module Notes
end
def
do_commands
(
note
,
update_params
,
message
,
only_commands
)
return
if
quick_actions_service
.
commands_executed_count
.
to_i
.
zero?
return
if
quick_actions_service
.
commands_executed_count
.
to_i
==
0
if
update_params
.
present?
quick_actions_service
.
apply_updates
(
update_params
,
note
)
...
...
app/services/packages/nuget/metadata_extraction_service.rb
View file @
c58ce73c
...
...
@@ -42,7 +42,7 @@ module Packages
def
valid_package_file?
package_file
&&
package_file
.
package
&
.
nuget?
&&
package_file
.
file
.
size
.
positive?
package_file
.
file
.
size
>
0
# rubocop:disable Style/ZeroLengthPredicate
end
def
extract_metadata
(
file
)
...
...
app/services/packages/nuget/search_service.rb
View file @
c58ce73c
...
...
@@ -21,8 +21,8 @@ module Packages
@search_term
=
search_term
@options
=
DEFAULT_OPTIONS
.
merge
(
options
)
raise
ArgumentError
,
'negative per_page'
if
per_page
.
negative?
raise
ArgumentError
,
'negative padding'
if
padding
.
negative?
raise
ArgumentError
,
'negative per_page'
if
per_page
<
0
raise
ArgumentError
,
'negative padding'
if
padding
<
0
end
def
execute
...
...
app/services/projects/auto_devops/disable_service.rb
View file @
c58ce73c
...
...
@@ -23,7 +23,7 @@ module Projects
# for more context.
# rubocop: disable CodeReuse/ActiveRecord
def
first_pipeline_failure?
auto_devops_pipelines
.
success
.
limit
(
1
).
count
.
zero?
&&
auto_devops_pipelines
.
success
.
limit
(
1
).
count
==
0
&&
auto_devops_pipelines
.
failed
.
limit
(
1
).
count
.
nonzero?
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/services/projects/update_pages_service.rb
View file @
c58ce73c
...
...
@@ -136,7 +136,7 @@ module Projects
def
max_size
max_pages_size
=
max_size_from_settings
return
::
Gitlab
::
Pages
::
MAX_SIZE
if
max_pages_size
.
zero?
return
::
Gitlab
::
Pages
::
MAX_SIZE
if
max_pages_size
==
0
max_pages_size
end
...
...
app/services/search_service.rb
View file @
c58ce73c
...
...
@@ -70,7 +70,7 @@ class SearchService
def
per_page
per_page_param
=
params
[
:per_page
].
to_i
return
DEFAULT_PER_PAGE
unless
per_page_param
.
positive?
return
DEFAULT_PER_PAGE
unless
per_page_param
>
0
[
MAX_PER_PAGE
,
per_page_param
].
min
end
...
...
app/workers/admin_email_worker.rb
View file @
c58ce73c
...
...
@@ -18,7 +18,7 @@ class AdminEmailWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord
def
send_repository_check_mail
repository_check_failed_count
=
Project
.
where
(
last_repository_check_failed:
true
).
count
return
if
repository_check_failed_count
.
zero?
return
if
repository_check_failed_count
==
0
RepositoryCheckMailer
.
notify
(
repository_check_failed_count
).
deliver_now
end
...
...
app/workers/gitlab/import/advance_stage.rb
View file @
c58ce73c
...
...
@@ -41,7 +41,7 @@ module Gitlab
# complete the work fast enough.
waiter
.
wait
(
BLOCKING_WAIT_TIME
)
next
unless
waiter
.
jobs_remaining
.
positive?
next
unless
waiter
.
jobs_remaining
>
0
new_waiters
[
waiter
.
key
]
=
waiter
.
jobs_remaining
end
...
...
config/initializers/validate_puma.rb
View file @
c58ce73c
# frozen_string_literal: true
if
Gitlab
::
Runtime
.
puma?
&&
::
Puma
.
cli_config
.
options
[
:workers
].
to_i
.
zero?
if
Gitlab
::
Runtime
.
puma?
&&
::
Puma
.
cli_config
.
options
[
:workers
].
to_i
==
0
raise
'Puma is only supported in Cluster-mode: workers > 0'
end
ee/app/controllers/security/projects_controller.rb
View file @
c58ce73c
...
...
@@ -25,7 +25,7 @@ module Security
end
def
destroy
if
!
remove_project
.
zero?
if
remove_project
!=
0
head
:ok
else
head
:no_content
...
...
ee/app/graphql/mutations/instance_security_dashboard/remove_project.rb
View file @
c58ce73c
...
...
@@ -18,7 +18,7 @@ module Mutations
result
=
remove_project
(
extract_project_id
(
id
))
{
errors:
result
.
zero?
?
[
'The project does not belong to your dashboard or you don\'t have permission to perform this action'
]
:
[]
errors:
result
==
0
?
[
'The project does not belong to your dashboard or you don\'t have permission to perform this action'
]
:
[]
}
end
...
...
ee/app/helpers/ee/timeboxes_helper.rb
View file @
c58ce73c
...
...
@@ -44,7 +44,7 @@ module EE
end
def
milestone_weight_tooltip_text
(
weight
)
if
weight
.
zero?
if
weight
==
0
_
(
"Weight"
)
else
_
(
"Weight %{weight}"
)
%
{
weight:
weight
}
...
...
ee/app/models/ci/minutes/quota.rb
View file @
c58ce73c
...
...
@@ -25,7 +25,7 @@ module Ci
def
monthly_percent_used
return
0
unless
namespace
.
shared_runners_minutes_limit_enabled?
return
0
if
monthly_minutes
.
zero?
return
0
if
monthly_minutes
==
0
100
*
monthly_minutes_used
.
to_i
/
monthly_minutes
end
...
...
@@ -38,7 +38,7 @@ module Ci
def
purchased_percent_used
return
0
unless
namespace
.
shared_runners_minutes_limit_enabled?
return
0
if
purchased_minutes
.
zero?
return
0
if
purchased_minutes
==
0
100
*
purchased_minutes_used
.
to_i
/
purchased_minutes
end
...
...
@@ -75,11 +75,11 @@ module Ci
end
def
no_minutes_purchased?
purchased_minutes
.
zero?
purchased_minutes
==
0
end
def
any_minutes_purchased?
purchased_minutes
.
positive?
purchased_minutes
>
0
end
# TODO: maps to NamespaceStatistics#shared_runners_minutes(include_extra: true)
...
...
ee/app/models/ee/ci/runner.rb
View file @
c58ce73c
...
...
@@ -26,7 +26,7 @@ module EE
def
visibility_levels_without_minutes_quota
::
Gitlab
::
VisibilityLevel
.
options
.
values
.
reject
do
|
visibility_level
|
minutes_cost_factor
(
visibility_level
)
.
positive?
minutes_cost_factor
(
visibility_level
)
>
0
end
end
...
...
ee/app/models/ee/project.rb
View file @
c58ce73c
...
...
@@ -630,7 +630,7 @@ module EE
def
adjourned_deletion?
feature_available?
(
:adjourned_deletion_for_projects_and_groups
)
&&
::
Gitlab
::
CurrentSettings
.
deletion_adjourned_period
.
positive?
&&
::
Gitlab
::
CurrentSettings
.
deletion_adjourned_period
>
0
&&
group_deletion_mode_configured?
end
...
...
ee/app/models/geo_node_status.rb
View file @
c58ce73c
...
...
@@ -356,7 +356,7 @@ class GeoNodeStatus < ApplicationRecord
@percentage_methods
<<
method_name
define_method
(
method_name
)
do
return
0
if
self
[
total
].
to_i
.
zero?
return
0
if
self
[
total
].
to_i
==
0
(
self
[
count
].
to_f
/
self
[
total
].
to_f
)
*
100.0
end
...
...
ee/app/models/license.rb
View file @
c58ce73c
...
...
@@ -541,9 +541,9 @@ class License < ApplicationRecord
return
if
restricted_user_count
>=
prior_historical_max
end
user_count
=
prior_historical_max
.
zero?
?
current_active_users_count
:
prior_historical_max
user_count
=
prior_historical_max
==
0
?
current_active_users_count
:
prior_historical_max
add_limit_error
(
current_period:
prior_historical_max
.
zero?
,
user_count:
user_count
)
add_limit_error
(
current_period:
prior_historical_max
==
0
,
user_count:
user_count
)
end
def
check_trueup
...
...
ee/app/models/namespace_statistics.rb
View file @
c58ce73c
...
...
@@ -18,7 +18,7 @@ class NamespaceStatistics < ApplicationRecord
limit
=
namespace
.
actual_shared_runners_minutes_limit
(
include_extra:
false
)
extra_limit
=
namespace
.
extra_shared_runners_minutes_limit
.
to_i
return
0
if
extra_limit
.
zero?
||
shared_runners_minutes
<=
limit
return
0
if
extra_limit
==
0
||
shared_runners_minutes
<=
limit
shared_runners_minutes
-
limit
end
...
...
ee/app/services/ee/issues/base_service.rb
View file @
c58ce73c
...
...
@@ -26,7 +26,7 @@ module EE
def
find_epic
(
issue
)
id
=
params
.
delete
(
:epic_id
)
return
if
id
.
to_i
.
zero?
return
if
id
.
to_i
==
0
group
=
issue
.
project
.
group
return
unless
group
.
present?
...
...
ee/app/services/ee/merge_requests/approval_service.rb
View file @
c58ce73c
...
...
@@ -28,7 +28,7 @@ module EE
override
:execute_approval_hooks
def
execute_approval_hooks
(
merge_request
,
current_user
)
if
merge_request
.
approvals_left
.
zero?
if
merge_request
.
approvals_left
==
0
notification_service
.
async
.
approve_mr
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'approved'
)
else
...
...
ee/app/services/ee/quick_actions/target_service.rb
View file @
c58ce73c
...
...
@@ -4,7 +4,7 @@ module EE
module
QuickActions
module
TargetService
def
execute
(
type
,
type_id
)
return
epic
(
type_id
)
if
type
.
casecmp
(
'epic'
)
.
zero?
return
epic
(
type_id
)
if
type
.
casecmp
(
'epic'
)
==
0
super
end
...
...
ee/app/services/elastic/indexing_control_service.rb
View file @
c58ce73c
...
...
@@ -65,7 +65,7 @@ module Elastic
remove_jobs_from_waiting_queue
(
redis
,
jobs_with_scores
)
end
redis
.
del
(
redis_set_key
,
redis_score_key
)
if
queue_size
.
zero?
redis
.
del
(
redis_set_key
,
redis_score_key
)
if
queue_size
==
0
end
end
...
...
ee/app/services/geo/hashed_storage_migration_service.rb
View file @
c58ce73c
...
...
@@ -46,7 +46,7 @@ module Geo
end
def
from_legacy_storage?
old_storage_version
.
nil?
||
old_storage_version
.
zero?
old_storage_version
.
nil?
||
old_storage_version
==
0
end
def
move_repository
...
...
ee/app/services/geo/prune_event_log_service.rb
View file @
c58ce73c
...
...
@@ -46,7 +46,7 @@ module Geo
deleted
=
relation
.
delete_with_limit
(
limit
)
if
deleted
.
positive?
if
deleted
>
0
log_info
(
'Rows pruned from Geo Event log'
,
relation:
relation
.
name
,
rows_deleted:
deleted
,
...
...
ee/app/services/security/waf_anomaly_summary_service.rb
View file @
c58ce73c
...
...
@@ -33,7 +33,7 @@ module Security
return
{
total_traffic:
nginx_total_requests
,
total_anomalous_traffic:
modsec_total_requests
}
if
totals_only
anomalous_traffic_count
=
nginx_total_requests
.
zero?
?
0
:
(
modsec_total_requests
/
nginx_total_requests
).
round
(
2
)
anomalous_traffic_count
=
nginx_total_requests
==
0
?
0
:
(
modsec_total_requests
/
nginx_total_requests
).
round
(
2
)
{
total_traffic:
nginx_total_requests
,
...
...
ee/app/services/update_build_minutes_service.rb
View file @
c58ce73c
...
...
@@ -15,7 +15,7 @@ class UpdateBuildMinutesService < BaseService
cost_factor
=
build
.
runner
.
minutes_cost_factor
(
project
.
visibility_level
)
duration_with_cost_factor
=
(
build
.
duration
*
cost_factor
).
to_i
return
unless
duration_with_cost_factor
.
positive?
return
unless
duration_with_cost_factor
>
0
ProjectStatistics
.
update_counters
(
project_statistics
,
shared_runners_seconds:
duration_with_cost_factor
)
...
...
ee/app/workers/geo/container_repository_sync_dispatch_worker.rb
View file @
c58ce73c
...
...
@@ -39,7 +39,7 @@ module Geo
resources
=
find_container_repository_ids_not_synced
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
if
remaining_capacity
.
zero?
if
remaining_capacity
==
0
resources
else
resources
+
find_retryable_container_registry_ids
(
batch_size:
remaining_capacity
)
...
...
ee/app/workers/geo/file_download_dispatch_worker.rb
View file @
c58ce73c
...
...
@@ -36,7 +36,7 @@ module Geo
resources
=
find_unsynced_jobs
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
count
if
remaining_capacity
.
zero?
if
remaining_capacity
==
0
resources
else
resources
+
find_low_priority_jobs
(
batch_size:
remaining_capacity
)
...
...
ee/app/workers/geo/registry_sync_worker.rb
View file @
c58ce73c
...
...
@@ -35,7 +35,7 @@ module Geo
resources
=
find_unsynced_jobs
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
count
if
remaining_capacity
.
zero?
if
remaining_capacity
==
0
resources
else
resources
+
find_low_priority_jobs
(
batch_size:
remaining_capacity
)
...
...
ee/app/workers/geo/repository_shard_sync_worker.rb
View file @
c58ce73c
...
...
@@ -67,7 +67,7 @@ module Geo
resources
=
find_project_ids_not_synced
(
except_ids:
scheduled_project_ids
,
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
if
remaining_capacity
.
zero?
if
remaining_capacity
==
0
resources
else
resources
+
find_project_ids_updated_recently
(
except_ids:
scheduled_project_ids
+
resources
,
batch_size:
remaining_capacity
)
...
...
ee/app/workers/geo/repository_verification/primary/shard_worker.rb
View file @
c58ce73c
...
...
@@ -49,11 +49,11 @@ module Geo
def
load_pending_resources
resources
=
find_never_verified_project_ids
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
return
resources
if
remaining_capacity
.
zero?
return
resources
if
remaining_capacity
==
0
resources
+=
find_recently_updated_project_ids
(
batch_size:
remaining_capacity
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
return
resources
if
remaining_capacity
.
zero?
return
resources
if
remaining_capacity
==
0
resources
+
find_project_ids_to_reverify
(
batch_size:
remaining_capacity
)
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