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
1dadba0b
Commit
1dadba0b
authored
Apr 26, 2021
by
Shubham Kumar
Committed by
Kerri Miller
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolves rubocop offense Performance/Count
parent
c765eb69
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
21 additions
and
29 deletions
+21
-29
.rubocop_todo.yml
.rubocop_todo.yml
+0
-13
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+2
-2
app/services/merge_requests/add_context_service.rb
app/services/merge_requests/add_context_service.rb
+1
-1
changelogs/unreleased/pl-rubocop-todo-count.yml
changelogs/unreleased/pl-rubocop-todo-count.yml
+5
-0
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
+1
-1
lib/gitlab/sidekiq_status.rb
lib/gitlab/sidekiq_status.rb
+1
-1
spec/lib/gitlab/conflict/file_spec.rb
spec/lib/gitlab/conflict/file_spec.rb
+6
-6
spec/lib/gitlab/git/tree_spec.rb
spec/lib/gitlab/git/tree_spec.rb
+3
-3
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+2
-2
No files found.
.rubocop_todo.yml
View file @
1dadba0b
...
...
@@ -266,19 +266,6 @@ Performance/CollectionLiteralInLoop:
Performance/ConstantRegexp
:
Enabled
:
false
# Offense count: 18
# Cop supports --auto-correct.
Performance/Count
:
Exclude
:
-
'
app/helpers/groups_helper.rb'
-
'
app/services/merge_requests/add_context_service.rb'
-
'
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb'
-
'
lib/gitlab/sidekiq_status.rb'
-
'
spec/lib/gitlab/conflict/file_spec.rb'
-
'
spec/lib/gitlab/git/tree_spec.rb'
-
'
spec/models/ci/build_spec.rb'
-
'
spec/support_specs/helpers/active_record/query_recorder_spec.rb'
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: SafeMultiline.
...
...
app/helpers/groups_helper.rb
View file @
1dadba0b
...
...
@@ -141,9 +141,9 @@ module GroupsHelper
def
projects_lfs_status
(
group
)
lfs_status
=
if
group
.
lfs_enabled?
group
.
projects
.
select
(
&
:lfs_enabled?
).
size
group
.
projects
.
count
(
&
:lfs_enabled?
)
else
group
.
projects
.
reject
(
&
:lfs_enabled?
).
size
group
.
projects
.
count
{
|
project
|
!
project
.
lfs_enabled?
}
end
size
=
group
.
projects
.
size
...
...
app/services/merge_requests/add_context_service.rb
View file @
1dadba0b
...
...
@@ -50,7 +50,7 @@ module MergeRequests
def
duplicates
existing_oids
=
merge_request
.
merge_request_context_commits
.
map
{
|
commit
|
commit
.
sha
.
to_s
}
existing_oids
.
select
do
|
existing_oid
|
commit_ids
.
select
{
|
commit_id
|
existing_oid
.
start_with?
(
commit_id
)
}.
count
>
0
commit_ids
.
count
{
|
commit_id
|
existing_oid
.
start_with?
(
commit_id
)
}
>
0
end
end
...
...
changelogs/unreleased/pl-rubocop-todo-count.yml
0 → 100644
View file @
1dadba0b
---
title
:
Resolve offense Performance/Count
merge_request
:
57007
author
:
Shubham Kumar (@imskr)
type
:
fixed
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
View file @
1dadba0b
...
...
@@ -88,7 +88,7 @@ module Gitlab
# {iid: 1, epic_state_id: 1, issues_count: 1, issues_weight_sum: 2, parent_id: nil, issues_state_id: 2}
if
type
==
EPIC_TYPE
# can only be COUNT
children
.
select
{
|
node
|
node
.
epic_state_id
==
state
}.
count
children
.
count
{
|
node
|
node
.
epic_state_id
==
state
}
else
matching_record
=
epic_info_flat_list
.
find
do
|
record
|
record
[
:issues_state_id
]
==
state
...
...
lib/gitlab/sidekiq_status.rb
View file @
1dadba0b
...
...
@@ -66,7 +66,7 @@ module Gitlab
def
self
.
num_running
(
job_ids
)
responses
=
self
.
job_status
(
job_ids
)
responses
.
select
(
&
:present?
).
count
responses
.
count
(
&
:present?
)
end
# Returns the number of jobs that have completed.
...
...
spec/lib/gitlab/conflict/file_spec.rb
View file @
1dadba0b
...
...
@@ -298,12 +298,12 @@ RSpec.describe Gitlab::Conflict::File do
end
it
'creates context sections of the correct length'
do
expect
(
sections
[
0
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
3
)
expect
(
sections
[
2
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
3
)
expect
(
sections
[
3
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
3
)
expect
(
sections
[
5
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
3
)
expect
(
sections
[
6
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
3
)
expect
(
sections
[
8
][
:lines
].
reject
(
&
:type
).
length
).
to
eq
(
1
)
expect
(
sections
[
0
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
3
)
expect
(
sections
[
2
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
3
)
expect
(
sections
[
3
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
3
)
expect
(
sections
[
5
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
3
)
expect
(
sections
[
6
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
3
)
expect
(
sections
[
8
][
:lines
].
count
{
|
line
|
line
.
type
.
nil?
}
).
to
eq
(
1
)
end
end
end
...
...
spec/lib/gitlab/git/tree_spec.rb
View file @
1dadba0b
...
...
@@ -10,9 +10,9 @@ RSpec.describe Gitlab::Git::Tree, :seed_helper do
it
{
expect
(
tree
).
to
be_kind_of
Array
}
it
{
expect
(
tree
.
empty?
).
to
be_falsey
}
it
{
expect
(
tree
.
select
(
&
:dir?
).
size
).
to
eq
(
2
)
}
it
{
expect
(
tree
.
select
(
&
:file?
).
size
).
to
eq
(
10
)
}
it
{
expect
(
tree
.
select
(
&
:submodule?
).
size
).
to
eq
(
2
)
}
it
{
expect
(
tree
.
count
(
&
:dir?
)
).
to
eq
(
2
)
}
it
{
expect
(
tree
.
count
(
&
:file?
)
).
to
eq
(
10
)
}
it
{
expect
(
tree
.
count
(
&
:submodule?
)
).
to
eq
(
2
)
}
it
'returns an empty array when called with an invalid ref'
do
expect
(
described_class
.
where
(
repository
,
'foobar-does-not-exist'
)).
to
eq
([])
...
...
spec/models/ci/build_spec.rb
View file @
1dadba0b
...
...
@@ -1132,7 +1132,7 @@ RSpec.describe Ci::Build do
it
"executes UPDATE query"
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
log
.
select
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}.
count
).
to
eq
(
1
)
expect
(
recorded
.
log
.
count
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}
).
to
eq
(
1
)
end
end
...
...
@@ -1140,7 +1140,7 @@ RSpec.describe Ci::Build do
it
'does not execute UPDATE query'
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
log
.
select
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}.
count
).
to
eq
(
0
)
expect
(
recorded
.
log
.
count
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}
).
to
eq
(
0
)
end
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