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
c223a602
Commit
c223a602
authored
Feb 23, 2022
by
Siddharth Asthana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve Performance/Sum rubocop offenses
Changelog: other EE: true
parent
92914b5a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
14 additions
and
31 deletions
+14
-31
.rubocop_todo.yml
.rubocop_todo.yml
+0
-17
app/controllers/projects/pipelines/tests_controller.rb
app/controllers/projects/pipelines/tests_controller.rb
+2
-2
app/models/application_setting_implementation.rb
app/models/application_setting_implementation.rb
+1
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
app/services/issues/export_csv_service.rb
app/services/issues/export_csv_service.rb
+1
-1
ee/spec/lib/gitlab/elastic/bulk_indexer_spec.rb
ee/spec/lib/gitlab/elastic/bulk_indexer_spec.rb
+2
-2
lib/api/entities/issuable_time_stats.rb
lib/api/entities/issuable_time_stats.rb
+1
-1
lib/container_registry/tag.rb
lib/container_registry/tag.rb
+1
-1
lib/gitlab/ci/reports/test_suite_comparer.rb
lib/gitlab/ci/reports/test_suite_comparer.rb
+1
-1
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+2
-2
lib/peek/views/detailed_view.rb
lib/peek/views/detailed_view.rb
+1
-1
spec/models/namespace/root_storage_statistics_spec.rb
spec/models/namespace/root_storage_statistics_spec.rb
+1
-1
No files found.
.rubocop_todo.yml
View file @
c223a602
...
...
@@ -311,23 +311,6 @@ Performance/StringInclude:
-
'
spec/spec_helper.rb'
-
'
spec/support_specs/helpers/active_record/query_recorder_spec.rb'
# Offense count: 18
# Cop supports --auto-correct.
Performance/Sum
:
Exclude
:
-
'
app/controllers/projects/pipelines/tests_controller.rb'
-
'
app/models/application_setting_implementation.rb'
-
'
app/models/ci/pipeline.rb'
-
'
app/services/issues/export_csv_service.rb'
-
'
ee/spec/lib/gitlab/elastic/bulk_indexer_spec.rb'
-
'
lib/api/entities/issuable_time_stats.rb'
-
'
lib/container_registry/tag.rb'
-
'
lib/gitlab/ci/reports/test_suite_comparer.rb'
-
'
lib/gitlab/diff/file.rb'
-
'
lib/gitlab/usage_data.rb'
-
'
lib/peek/views/detailed_view.rb'
-
'
spec/models/namespace/root_storage_statistics_spec.rb'
# Offense count: 15209
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
...
...
app/controllers/projects/pipelines/tests_controller.rb
View file @
c223a602
...
...
@@ -42,9 +42,9 @@ module Projects
end
def
test_suite
suite
=
builds
.
map
do
|
build
|
suite
=
builds
.
sum
do
|
build
|
build
.
collect_test_reports!
(
Gitlab
::
Ci
::
Reports
::
TestReports
.
new
)
end
.
sum
end
Gitlab
::
Ci
::
Reports
::
TestFailureHistory
.
new
(
suite
.
failed
.
values
,
project
).
load!
...
...
app/models/application_setting_implementation.rb
View file @
c223a602
...
...
@@ -403,7 +403,7 @@ module ApplicationSettingImplementation
def
normalized_repository_storage_weights
strong_memoize
(
:normalized_repository_storage_weights
)
do
repository_storages_weights
=
repository_storages_weighted
.
slice
(
*
Gitlab
.
config
.
repositories
.
storages
.
keys
)
weights_total
=
repository_storages_weights
.
values
.
reduce
(:
+
)
weights_total
=
repository_storages_weights
.
values
.
sum
repository_storages_weights
.
transform_values
do
|
w
|
next
w
if
weights_total
==
0
...
...
app/models/ci/pipeline.rb
View file @
c223a602
...
...
@@ -653,7 +653,7 @@ module Ci
def
coverage
coverage_array
=
latest_statuses
.
map
(
&
:coverage
).
compact
if
coverage_array
.
size
>=
1
coverage_array
.
reduce
(:
+
)
/
coverage_array
.
size
coverage_array
.
sum
/
coverage_array
.
size
end
end
...
...
app/services/issues/export_csv_service.rb
View file @
c223a602
...
...
@@ -52,7 +52,7 @@ module Issues
# rubocop: disable CodeReuse/ActiveRecord
def
issue_time_spent
(
issue
)
issue
.
timelogs
.
map
(
&
:time_spent
).
sum
issue
.
timelogs
.
sum
(
&
:time_spent
)
end
# rubocop: enable CodeReuse/ActiveRecord
end
...
...
ee/spec/lib/gitlab/elastic/bulk_indexer_spec.rb
View file @
c223a602
...
...
@@ -53,7 +53,7 @@ RSpec.describe Gitlab::Elastic::BulkIndexer, :elastic, :clean_gitlab_redis_share
indexer
.
process
(
issue_as_ref
)
expect
(
es_client
).
to
have_received
(
:bulk
)
do
|
args
|
body_bytesize
=
args
[
:body
].
map
(
&
:bytesize
).
reduce
(:
+
)
body_bytesize
=
args
[
:body
].
sum
(
&
:bytesize
)
expect
(
body_bytesize
).
to
be
<=
bulk_limit_bytes
end
...
...
@@ -109,7 +109,7 @@ RSpec.describe Gitlab::Elastic::BulkIndexer, :elastic, :clean_gitlab_redis_share
indexer
.
process
(
issue_as_ref
)
expect
(
es_client
).
to
have_received
(
:bulk
)
do
|
args
|
body_bytesize
=
args
[
:body
].
map
(
&
:bytesize
).
reduce
(:
+
)
body_bytesize
=
args
[
:body
].
sum
(
&
:bytesize
)
expect
(
body_bytesize
).
to
be
<=
bulk_limit_bytes
end
...
...
lib/api/entities/issuable_time_stats.rb
View file @
c223a602
...
...
@@ -18,7 +18,7 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def
total_time_spent
# Avoids an N+1 query since timelogs are preloaded
object
.
timelogs
.
map
(
&
:time_spent
).
sum
object
.
timelogs
.
sum
(
&
:time_spent
)
end
# rubocop: enable CodeReuse/ActiveRecord
end
...
...
lib/container_registry/tag.rb
View file @
c223a602
...
...
@@ -104,7 +104,7 @@ module ContainerRegistry
def
total_size
return
unless
layers
layers
.
map
(
&
:size
).
sum
if
v2?
layers
.
sum
(
&
:size
)
if
v2?
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
lib/gitlab/ci/reports/test_suite_comparer.rb
View file @
c223a602
...
...
@@ -106,7 +106,7 @@ module Gitlab
private
def
max_tests
(
*
used
)
[
DEFAULT_MAX_TESTS
-
used
.
map
(
&
:count
).
sum
,
DEFAULT_MIN_TESTS
].
max
[
DEFAULT_MAX_TESTS
-
used
.
sum
(
&
:count
)
,
DEFAULT_MIN_TESTS
].
max
end
end
end
...
...
lib/gitlab/diff/file.rb
View file @
c223a602
...
...
@@ -296,13 +296,13 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
size
valid_blobs
.
map
(
&
:size
).
sum
valid_blobs
.
sum
(
&
:size
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
raw_size
valid_blobs
.
map
(
&
:raw_size
).
sum
valid_blobs
.
sum
(
&
:raw_size
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
lib/peek/views/detailed_view.rb
View file @
c223a602
...
...
@@ -23,7 +23,7 @@ module Peek
private
def
duration
detail_store
.
map
{
|
entry
|
entry
[
:duration
]
}.
sum
*
1000
detail_store
.
sum
{
|
entry
|
entry
[
:duration
]
}
*
1000
end
def
calls
...
...
spec/models/namespace/root_storage_statistics_spec.rb
View file @
c223a602
...
...
@@ -178,7 +178,7 @@ RSpec.describe Namespace::RootStorageStatistics, type: :model do
snippets
=
create_list
(
:personal_snippet
,
3
,
:repository
,
author:
user
)
snippets
.
each
{
|
s
|
s
.
statistics
.
refresh!
}
total_personal_snippets_size
=
snippets
.
map
{
|
s
|
s
.
statistics
.
repository_size
}.
sum
total_personal_snippets_size
=
snippets
.
sum
{
|
s
|
s
.
statistics
.
repository_size
}
root_storage_statistics
.
recalculate!
...
...
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