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
f5e335dd
Commit
f5e335dd
authored
Aug 04, 2020
by
Doug Stull
Committed by
Michael Kozono
Aug 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve Style/NumericPredicate cop exceptions in specs
- no exceptions...
parent
2a5ebef6
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
21 additions
and
24 deletions
+21
-24
.rubocop_todo.yml
.rubocop_todo.yml
+0
-3
qa/qa/git/repository.rb
qa/qa/git/repository.rb
+1
-1
qa/qa/support/wait_for_requests.rb
qa/qa/support/wait_for_requests.rb
+2
-2
spec/config/mail_room_spec.rb
spec/config/mail_room_spec.rb
+1
-1
spec/controllers/groups/settings/repository_controller_spec.rb
...controllers/groups/settings/repository_controller_spec.rb
+1
-1
spec/controllers/projects/settings/repository_controller_spec.rb
...ntrollers/projects/settings/repository_controller_spec.rb
+1
-1
spec/factories/design_management/designs.rb
spec/factories/design_management/designs.rb
+1
-1
spec/factories/design_management/versions.rb
spec/factories/design_management/versions.rb
+1
-1
spec/features/calendar_spec.rb
spec/features/calendar_spec.rb
+1
-1
spec/lib/gitlab/git/diff_collection_spec.rb
spec/lib/gitlab/git/diff_collection_spec.rb
+1
-1
spec/lib/gitlab/github_import/client_spec.rb
spec/lib/gitlab/github_import/client_spec.rb
+1
-1
spec/lib/gitlab/popen/runner_spec.rb
spec/lib/gitlab/popen/runner_spec.rb
+1
-1
spec/lib/gitlab/tree_summary_spec.rb
spec/lib/gitlab/tree_summary_spec.rb
+2
-2
spec/support/helpers/bare_repo_operations.rb
spec/support/helpers/bare_repo_operations.rb
+1
-1
spec/support/helpers/memory_usage_helper.rb
spec/support/helpers/memory_usage_helper.rb
+1
-1
spec/support/helpers/wait_for_requests.rb
spec/support/helpers/wait_for_requests.rb
+3
-3
spec/support/matchers/exceed_query_limit.rb
spec/support/matchers/exceed_query_limit.rb
+2
-2
No files found.
.rubocop_todo.yml
View file @
f5e335dd
...
@@ -1025,7 +1025,6 @@ Style/NumericLiteralPrefix:
...
@@ -1025,7 +1025,6 @@ Style/NumericLiteralPrefix:
Style/NumericPredicate
:
Style/NumericPredicate
:
EnforcedStyle
:
comparison
EnforcedStyle
:
comparison
Exclude
:
Exclude
:
-
'
spec/**/*'
-
'
app/controllers/concerns/issuable_collections.rb'
-
'
app/controllers/concerns/issuable_collections.rb'
-
'
app/controllers/concerns/paginated_collection.rb'
-
'
app/controllers/concerns/paginated_collection.rb'
-
'
app/helpers/graph_helper.rb'
-
'
app/helpers/graph_helper.rb'
...
@@ -1126,8 +1125,6 @@ Style/NumericPredicate:
...
@@ -1126,8 +1125,6 @@ Style/NumericPredicate:
-
'
lib/tasks/gitlab/gitaly.rake'
-
'
lib/tasks/gitlab/gitaly.rake'
-
'
lib/tasks/gitlab/snippets.rake'
-
'
lib/tasks/gitlab/snippets.rake'
-
'
lib/tasks/gitlab/workhorse.rake'
-
'
lib/tasks/gitlab/workhorse.rake'
-
'
qa/qa/git/repository.rb'
-
'
qa/qa/support/wait_for_requests.rb'
-
'
ee/app/models/ee/project.rb'
-
'
ee/app/models/ee/project.rb'
-
'
lib/gitlab/usage_data/topology.rb'
-
'
lib/gitlab/usage_data/topology.rb'
...
...
qa/qa/git/repository.rb
View file @
f5e335dd
...
@@ -204,7 +204,7 @@ module QA
...
@@ -204,7 +204,7 @@ module QA
alias_method
:to_s
,
:response
alias_method
:to_s
,
:response
def
success?
def
success?
exitstatus
.
zero?
exitstatus
==
0
end
end
end
end
...
...
qa/qa/support/wait_for_requests.rb
View file @
f5e335dd
...
@@ -14,13 +14,13 @@ module QA
...
@@ -14,13 +14,13 @@ module QA
end
end
def
finished_all_axios_requests?
def
finished_all_axios_requests?
Capybara
.
page
.
evaluate_script
(
'window.pendingRequests || 0'
).
zero?
Capybara
.
page
.
evaluate_script
(
'window.pendingRequests || 0'
).
zero?
# rubocop:disable Style/NumericPredicate
end
end
def
finished_all_ajax_requests?
def
finished_all_ajax_requests?
return
true
if
Capybara
.
page
.
evaluate_script
(
'typeof jQuery === "undefined"'
)
return
true
if
Capybara
.
page
.
evaluate_script
(
'typeof jQuery === "undefined"'
)
Capybara
.
page
.
evaluate_script
(
'jQuery.active'
).
zero?
Capybara
.
page
.
evaluate_script
(
'jQuery.active'
).
zero?
# rubocop:disable Style/NumericPredicate
end
end
def
finished_loading?
(
wait:
DEFAULT_MAX_WAIT_TIME
)
def
finished_loading?
(
wait:
DEFAULT_MAX_WAIT_TIME
)
...
...
spec/config/mail_room_spec.rb
View file @
f5e335dd
...
@@ -17,7 +17,7 @@ RSpec.describe 'mail_room.yml' do
...
@@ -17,7 +17,7 @@ RSpec.describe 'mail_room.yml' do
cmd
=
"puts ERB.new(File.read(
#{
absolute_path
(
mailroom_config_path
).
inspect
}
)).result"
cmd
=
"puts ERB.new(File.read(
#{
absolute_path
(
mailroom_config_path
).
inspect
}
)).result"
output
,
status
=
Gitlab
::
Popen
.
popen
(
%W(ruby -rerb -e
#{
cmd
}
)
,
absolute_path
(
'config'
),
vars
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
%W(ruby -rerb -e
#{
cmd
}
)
,
absolute_path
(
'config'
),
vars
)
raise
"Error interpreting
#{
mailroom_config_path
}
:
#{
output
}
"
unless
status
.
zero?
raise
"Error interpreting
#{
mailroom_config_path
}
:
#{
output
}
"
unless
status
==
0
YAML
.
load
(
output
)
YAML
.
load
(
output
)
end
end
...
...
spec/controllers/groups/settings/repository_controller_spec.rb
View file @
f5e335dd
...
@@ -60,7 +60,7 @@ RSpec.describe Groups::Settings::RepositoryController do
...
@@ -60,7 +60,7 @@ RSpec.describe Groups::Settings::RepositoryController do
'token'
=>
be_a
(
String
),
'token'
=>
be_a
(
String
),
'scopes'
=>
deploy_token_params
.
inject
([])
do
|
scopes
,
kv
|
'scopes'
=>
deploy_token_params
.
inject
([])
do
|
scopes
,
kv
|
key
,
value
=
kv
key
,
value
=
kv
key
.
to_s
.
start_with?
(
'read_'
)
&&
!
value
.
to_i
.
zero?
?
scopes
<<
key
.
to_s
:
scopes
key
.
to_s
.
start_with?
(
'read_'
)
&&
value
.
to_i
!=
0
?
scopes
<<
key
.
to_s
:
scopes
end
end
}
}
end
end
...
...
spec/controllers/projects/settings/repository_controller_spec.rb
View file @
f5e335dd
...
@@ -77,7 +77,7 @@ RSpec.describe Projects::Settings::RepositoryController do
...
@@ -77,7 +77,7 @@ RSpec.describe Projects::Settings::RepositoryController do
'token'
=>
be_a
(
String
),
'token'
=>
be_a
(
String
),
'scopes'
=>
deploy_token_params
.
inject
([])
do
|
scopes
,
kv
|
'scopes'
=>
deploy_token_params
.
inject
([])
do
|
scopes
,
kv
|
key
,
value
=
kv
key
,
value
=
kv
key
.
to_s
.
start_with?
(
'read_'
)
&&
!
value
.
to_i
.
zero?
?
scopes
<<
key
.
to_s
:
scopes
key
.
to_s
.
start_with?
(
'read_'
)
&&
value
.
to_i
!=
0
?
scopes
<<
key
.
to_s
:
scopes
end
end
}
}
end
end
...
...
spec/factories/design_management/designs.rb
View file @
f5e335dd
...
@@ -23,7 +23,7 @@ FactoryBot.define do
...
@@ -23,7 +23,7 @@ FactoryBot.define do
end
end
create_versions
=
->
(
design
,
evaluator
,
commit_version
)
do
create_versions
=
->
(
design
,
evaluator
,
commit_version
)
do
unless
evaluator
.
versions_count
.
zero?
unless
evaluator
.
versions_count
==
0
project
=
design
.
project
project
=
design
.
project
issue
=
design
.
issue
issue
=
design
.
issue
repository
=
project
.
design_repository
repository
=
project
.
design_repository
...
...
spec/factories/design_management/versions.rb
View file @
f5e335dd
...
@@ -40,7 +40,7 @@ FactoryBot.define do
...
@@ -40,7 +40,7 @@ FactoryBot.define do
)
)
version
.
designs
+=
specific_designs
version
.
designs
+=
specific_designs
unless
evaluator
.
designs_count
.
zero?
||
version
.
designs
.
present?
unless
evaluator
.
designs_count
==
0
||
version
.
designs
.
present?
version
.
designs
<<
create
(
:design
,
issue:
version
.
issue
)
version
.
designs
<<
create
(
:design
,
issue:
version
.
issue
)
end
end
end
end
...
...
spec/features/calendar_spec.rb
View file @
f5e335dd
...
@@ -36,7 +36,7 @@ RSpec.describe 'Contributions Calendar', :js do
...
@@ -36,7 +36,7 @@ RSpec.describe 'Contributions Calendar', :js do
def
get_cell_date_selector
(
contributions
,
date
)
def
get_cell_date_selector
(
contributions
,
date
)
contribution_text
=
contribution_text
=
if
contributions
.
zero?
if
contributions
==
0
'No contributions'
'No contributions'
else
else
"
#{
contributions
}
#{
'contribution'
.
pluralize
(
contributions
)
}
"
"
#{
contributions
}
#{
'contribution'
.
pluralize
(
contributions
)
}
"
...
...
spec/lib/gitlab/git/diff_collection_spec.rb
View file @
f5e335dd
...
@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Git::DiffCollection, :seed_helper do
...
@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Git::DiffCollection, :seed_helper do
return
enum_for
(
:each
)
unless
block_given?
return
enum_for
(
:each
)
unless
block_given?
loop
do
loop
do
break
if
@count
.
zero?
break
if
@count
==
0
# It is critical to decrement before yielding. We may never reach the lines after 'yield'.
# It is critical to decrement before yielding. We may never reach the lines after 'yield'.
@count
-=
1
@count
-=
1
...
...
spec/lib/gitlab/github_import/client_spec.rb
View file @
f5e335dd
...
@@ -169,7 +169,7 @@ RSpec.describe Gitlab::GithubImport::Client do
...
@@ -169,7 +169,7 @@ RSpec.describe Gitlab::GithubImport::Client do
expect
(
client
).
to
receive
(
:raise_or_wait_for_rate_limit
)
expect
(
client
).
to
receive
(
:raise_or_wait_for_rate_limit
)
client
.
with_rate_limit
do
client
.
with_rate_limit
do
if
retries
.
zero?
if
retries
==
0
retries
+=
1
retries
+=
1
raise
(
Octokit
::
TooManyRequests
)
raise
(
Octokit
::
TooManyRequests
)
end
end
...
...
spec/lib/gitlab/popen/runner_spec.rb
View file @
f5e335dd
...
@@ -118,7 +118,7 @@ RSpec.describe Gitlab::Popen::Runner do
...
@@ -118,7 +118,7 @@ RSpec.describe Gitlab::Popen::Runner do
stdout:
'stdout'
,
stdout:
'stdout'
,
stderr:
''
,
stderr:
''
,
exitstatus:
0
,
exitstatus:
0
,
status:
double
(
exitstatus:
exitstatus
,
success?:
exitstatus
.
zero?
),
status:
double
(
exitstatus:
exitstatus
,
success?:
exitstatus
==
0
),
duration:
0.1
)
duration:
0.1
)
result
=
result
=
...
...
spec/lib/gitlab/tree_summary_spec.rb
View file @
f5e335dd
...
@@ -191,7 +191,7 @@ RSpec.describe Gitlab::TreeSummary do
...
@@ -191,7 +191,7 @@ RSpec.describe Gitlab::TreeSummary do
with_them
do
with_them
do
before
do
before
do
create_file
(
'dummy'
,
path:
'other'
)
if
num_entries
.
zero?
create_file
(
'dummy'
,
path:
'other'
)
if
num_entries
==
0
1
.
upto
(
num_entries
)
{
|
n
|
create_file
(
n
,
path:
path
)
}
1
.
upto
(
num_entries
)
{
|
n
|
create_file
(
n
,
path:
path
)
}
end
end
...
@@ -218,7 +218,7 @@ RSpec.describe Gitlab::TreeSummary do
...
@@ -218,7 +218,7 @@ RSpec.describe Gitlab::TreeSummary do
with_them
do
with_them
do
before
do
before
do
create_file
(
'dummy'
,
path:
'other'
)
if
num_entries
.
zero?
create_file
(
'dummy'
,
path:
'other'
)
if
num_entries
==
0
1
.
upto
(
num_entries
)
{
|
n
|
create_file
(
n
,
path:
path
)
}
1
.
upto
(
num_entries
)
{
|
n
|
create_file
(
n
,
path:
path
)
}
end
end
...
...
spec/support/helpers/bare_repo_operations.rb
View file @
f5e335dd
...
@@ -44,7 +44,7 @@ class BareRepoOperations
...
@@ -44,7 +44,7 @@ class BareRepoOperations
yield
stdin
if
block_given?
yield
stdin
if
block_given?
end
end
unless
status
.
zero?
unless
status
==
0
if
allow_failure
if
allow_failure
return
[]
return
[]
else
else
...
...
spec/support/helpers/memory_usage_helper.rb
View file @
f5e335dd
...
@@ -21,7 +21,7 @@ module MemoryUsageHelper
...
@@ -21,7 +21,7 @@ module MemoryUsageHelper
def
get_memory_usage
def
get_memory_usage
output
,
status
=
Gitlab
::
Popen
.
popen
(
%w(free -m)
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
%w(free -m)
)
abort
"`free -m` return code is
#{
status
}
:
#{
output
}
"
unless
status
.
zero?
abort
"`free -m` return code is
#{
status
}
:
#{
output
}
"
unless
status
==
0
result
=
output
.
split
(
"
\n
"
)[
1
].
split
(
" "
)[
1
..-
1
]
result
=
output
.
split
(
"
\n
"
)[
1
].
split
(
" "
)[
1
..-
1
]
attrs
=
%i(m_total m_used m_free m_shared m_buffers_cache m_available)
.
freeze
attrs
=
%i(m_total m_used m_free m_shared m_buffers_cache m_available)
.
freeze
...
...
spec/support/helpers/wait_for_requests.rb
View file @
f5e335dd
...
@@ -42,7 +42,7 @@ module WaitForRequests
...
@@ -42,7 +42,7 @@ module WaitForRequests
private
private
def
finished_all_rack_requests?
def
finished_all_rack_requests?
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
num_active_requests
.
zero?
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
num_active_requests
==
0
end
end
def
finished_all_js_requests?
def
finished_all_js_requests?
...
@@ -53,12 +53,12 @@ module WaitForRequests
...
@@ -53,12 +53,12 @@ module WaitForRequests
end
end
def
finished_all_axios_requests?
def
finished_all_axios_requests?
Capybara
.
page
.
evaluate_script
(
'window.pendingRequests || 0'
).
zero?
Capybara
.
page
.
evaluate_script
(
'window.pendingRequests || 0'
).
zero?
# rubocop:disable Style/NumericPredicate
end
end
def
finished_all_ajax_requests?
def
finished_all_ajax_requests?
return
true
if
Capybara
.
page
.
evaluate_script
(
'typeof jQuery === "undefined"'
)
return
true
if
Capybara
.
page
.
evaluate_script
(
'typeof jQuery === "undefined"'
)
Capybara
.
page
.
evaluate_script
(
'jQuery.active'
).
zero?
Capybara
.
page
.
evaluate_script
(
'jQuery.active'
).
zero?
# rubocop:disable Style/NumericPredicate
end
end
end
end
spec/support/matchers/exceed_query_limit.rb
View file @
f5e335dd
...
@@ -44,7 +44,7 @@ module ExceedQueryLimitHelpers
...
@@ -44,7 +44,7 @@ module ExceedQueryLimitHelpers
def
log_message
def
log_message
if
expected
.
is_a?
(
ActiveRecord
::
QueryRecorder
)
if
expected
.
is_a?
(
ActiveRecord
::
QueryRecorder
)
counts
=
count_queries
(
strip_marginalia_annotations
(
expected
.
log
))
counts
=
count_queries
(
strip_marginalia_annotations
(
expected
.
log
))
extra_queries
=
strip_marginalia_annotations
(
@recorder
.
log
).
reject
{
|
query
|
counts
[
query
]
-=
1
unless
counts
[
query
]
.
zero?
}
extra_queries
=
strip_marginalia_annotations
(
@recorder
.
log
).
reject
{
|
query
|
counts
[
query
]
-=
1
unless
counts
[
query
]
==
0
}
extra_queries_display
=
count_queries
(
extra_queries
).
map
{
|
query
,
count
|
"[
#{
count
}
]
#{
query
}
"
}
extra_queries_display
=
count_queries
(
extra_queries
).
map
{
|
query
,
count
|
"[
#{
count
}
]
#{
query
}
"
}
([
'Extra queries:'
]
+
extra_queries_display
).
join
(
"
\n\n
"
)
([
'Extra queries:'
]
+
extra_queries_display
).
join
(
"
\n\n
"
)
...
@@ -188,7 +188,7 @@ RSpec::Matchers.define :issue_same_number_of_queries_as do
...
@@ -188,7 +188,7 @@ RSpec::Matchers.define :issue_same_number_of_queries_as do
def
expected_count_message
def
expected_count_message
or_fewer_msg
=
"or fewer"
if
@or_fewer
or_fewer_msg
=
"or fewer"
if
@or_fewer
threshold_msg
=
"(+/-
#{
threshold
}
)"
unless
threshold
.
zero?
threshold_msg
=
"(+/-
#{
threshold
}
)"
unless
threshold
==
0
[
"
#{
expected_count
}
"
,
or_fewer_msg
,
threshold_msg
].
compact
.
join
(
' '
)
[
"
#{
expected_count
}
"
,
or_fewer_msg
,
threshold_msg
].
compact
.
join
(
' '
)
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