Commit f5e335dd authored by Doug Stull's avatar Doug Stull Committed by Michael Kozono

Resolve Style/NumericPredicate cop exceptions in specs

- no exceptions...
parent 2a5ebef6
......@@ -1025,7 +1025,6 @@ Style/NumericLiteralPrefix:
Style/NumericPredicate:
EnforcedStyle: comparison
Exclude:
- 'spec/**/*'
- 'app/controllers/concerns/issuable_collections.rb'
- 'app/controllers/concerns/paginated_collection.rb'
- 'app/helpers/graph_helper.rb'
......@@ -1126,8 +1125,6 @@ Style/NumericPredicate:
- 'lib/tasks/gitlab/gitaly.rake'
- 'lib/tasks/gitlab/snippets.rake'
- 'lib/tasks/gitlab/workhorse.rake'
- 'qa/qa/git/repository.rb'
- 'qa/qa/support/wait_for_requests.rb'
- 'ee/app/models/ee/project.rb'
- 'lib/gitlab/usage_data/topology.rb'
......
......@@ -204,7 +204,7 @@ module QA
alias_method :to_s, :response
def success?
exitstatus.zero?
exitstatus == 0
end
end
......
......@@ -14,13 +14,13 @@ module QA
end
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
def finished_all_ajax_requests?
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
def finished_loading?(wait: DEFAULT_MAX_WAIT_TIME)
......
......@@ -17,7 +17,7 @@ RSpec.describe 'mail_room.yml' do
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)
raise "Error interpreting #{mailroom_config_path}: #{output}" unless status.zero?
raise "Error interpreting #{mailroom_config_path}: #{output}" unless status == 0
YAML.load(output)
end
......
......@@ -60,7 +60,7 @@ RSpec.describe Groups::Settings::RepositoryController do
'token' => be_a(String),
'scopes' => deploy_token_params.inject([]) do |scopes, 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
......
......@@ -77,7 +77,7 @@ RSpec.describe Projects::Settings::RepositoryController do
'token' => be_a(String),
'scopes' => deploy_token_params.inject([]) do |scopes, 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
......
......@@ -23,7 +23,7 @@ FactoryBot.define do
end
create_versions = ->(design, evaluator, commit_version) do
unless evaluator.versions_count.zero?
unless evaluator.versions_count == 0
project = design.project
issue = design.issue
repository = project.design_repository
......
......@@ -40,7 +40,7 @@ FactoryBot.define do
)
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)
end
end
......
......@@ -36,7 +36,7 @@ RSpec.describe 'Contributions Calendar', :js do
def get_cell_date_selector(contributions, date)
contribution_text =
if contributions.zero?
if contributions == 0
'No contributions'
else
"#{contributions} #{'contribution'.pluralize(contributions)}"
......
......@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Git::DiffCollection, :seed_helper do
return enum_for(:each) unless block_given?
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'.
@count -= 1
......
......@@ -169,7 +169,7 @@ RSpec.describe Gitlab::GithubImport::Client do
expect(client).to receive(:raise_or_wait_for_rate_limit)
client.with_rate_limit do
if retries.zero?
if retries == 0
retries += 1
raise(Octokit::TooManyRequests)
end
......
......@@ -118,7 +118,7 @@ RSpec.describe Gitlab::Popen::Runner do
stdout: 'stdout',
stderr: '',
exitstatus: 0,
status: double(exitstatus: exitstatus, success?: exitstatus.zero?),
status: double(exitstatus: exitstatus, success?: exitstatus == 0),
duration: 0.1)
result =
......
......@@ -191,7 +191,7 @@ RSpec.describe Gitlab::TreeSummary do
with_them 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) }
end
......@@ -218,7 +218,7 @@ RSpec.describe Gitlab::TreeSummary do
with_them 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) }
end
......
......@@ -44,7 +44,7 @@ class BareRepoOperations
yield stdin if block_given?
end
unless status.zero?
unless status == 0
if allow_failure
return []
else
......
......@@ -21,7 +21,7 @@ module MemoryUsageHelper
def get_memory_usage
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]
attrs = %i(m_total m_used m_free m_shared m_buffers_cache m_available).freeze
......
......@@ -42,7 +42,7 @@ module WaitForRequests
private
def finished_all_rack_requests?
Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero?
Gitlab::Testing::RequestBlockerMiddleware.num_active_requests == 0
end
def finished_all_js_requests?
......@@ -53,12 +53,12 @@ module WaitForRequests
end
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
def finished_all_ajax_requests?
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
......@@ -44,7 +44,7 @@ module ExceedQueryLimitHelpers
def log_message
if expected.is_a?(ActiveRecord::QueryRecorder)
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:'] + extra_queries_display).join("\n\n")
......@@ -188,7 +188,7 @@ RSpec::Matchers.define :issue_same_number_of_queries_as do
def expected_count_message
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(' ')
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment