Skip to content

Commit 3e1ffbc

Browse files
committed
Enable CollectionQuerying
- had to use -A on rubocop to autofix
1 parent 9d6e524 commit 3e1ffbc

File tree

12 files changed

+17
-15
lines changed

12 files changed

+17
-15
lines changed

.rubocop_cc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ Style/ArrayIntersectWithSingleElement:
271271
Enabled: true
272272
Style/BitwisePredicate:
273273
Enabled: true
274+
Style/CollectionQuerying:
275+
Enabled: true
274276
Style/CollectionCompact:
275277
Enabled: true
276278
Style/CombinableDefined:

app/access/organization_access.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ def validate!(org, params)
8888
end
8989

9090
def validate_remove_billing_manager_by_guid!(org)
91-
return if org.billing_managers_dataset.count > 1
91+
return if org.billing_managers_dataset.many?
9292

9393
raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg')
9494
end
9595

9696
def validate_remove_manager_by_guid!(org)
97-
return if org.managers_dataset.count > 1
97+
return if org.managers_dataset.many?
9898

9999
raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg')
100100
end
101101

102102
def validate_remove_user_by_guid!(org, user_guid)
103-
raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.count == 1 && org.managers.first.guid == user_guid
103+
raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.one? && org.managers.first.guid == user_guid
104104

105-
raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.count == 1 && org.billing_managers.first.guid == user_guid
105+
raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.one? && org.billing_managers.first.guid == user_guid
106106

107-
return unless org.users_dataset.count == 1 && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1
107+
return unless org.users_dataset.one? && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1
108108

109109
raise CloudController::Errors::ApiError.new_from_details('LastUserInOrg')
110110
end

app/jobs/runtime/failed_jobs_cleanup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def perform
2626
orphaned_delayed_jobs = Delayed::Job.
2727
where(Sequel.lit("run_at < CURRENT_TIMESTAMP - INTERVAL '?' DAY", force_delete_after))
2828

29-
unless orphaned_delayed_jobs.count.zero?
29+
unless orphaned_delayed_jobs.none?
3030
logger.info("Deleting #{orphaned_delayed_jobs.count} orphaned Delayed Jobs older than #{force_delete_after} days")
3131

3232
orphaned_delayed_jobs.delete

db/migrations/20161005205815_fix_droplets_process_types_json.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def add_command(command, id)
1212
end
1313

1414
def flush
15-
if @batched_commands.count > 0
15+
if @batched_commands.any?
1616
cases = []
1717
ids = []
1818
id_place_holders = []

db/migrations/20231205143526_remove_deployments_with_degenerate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
up do
33
degenerate_records = self[:deployments].where(status_reason: 'DEGENERATE')
44

5-
if degenerate_records.count > 0
5+
if degenerate_records.any?
66
guids_dataset = degenerate_records.select(:guid)
77
self[:deployment_processes].where(deployment_guid: guids_dataset).delete
88
self[:deployment_labels].where(resource_guid: guids_dataset).delete

lib/cloud_controller/diego/docker/staging_action_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def action
1717
"-dockerRef=#{staging_details.package.image}"
1818
]
1919

20-
if config.get(:diego, :insecure_docker_registry_list).count > 0
20+
if config.get(:diego, :insecure_docker_registry_list).any?
2121
insecure_registries = "-insecureDockerRegistries=#{config.get(:diego, :insecure_docker_registry_list).join(',')}"
2222
run_args << insecure_registries
2323
end

lib/cloud_controller/errands/rotate_database_key.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def rotate_for_class(klass, batch_size)
3232
rows = rows_needing_rotation.
3333
limit(batch_size).
3434
all
35-
break if rows.count == 0
35+
break if rows.none?
3636

3737
klass.instance_exec do
3838
@allow_manual_timestamp_update = true

lib/cloud_controller/seeds.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def find_routing_guid(domain)
124124
end
125125

126126
def create_seed_security_groups(config)
127-
return unless config.get(:security_group_definitions) && SecurityGroup.count == 0
127+
return unless config.get(:security_group_definitions) && SecurityGroup.none?
128128

129129
config.get(:security_group_definitions).each do |security_group|
130130
seed_security_group = security_group.dup

lib/sequel_plugins/vcap_relations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.apply(model)
66

77
module InstanceMethods
88
def has_one_to_many?(association)
9-
association_type(association) == :one_to_many && send(association).count > 0
9+
association_type(association) == :one_to_many && send(association).any?
1010
end
1111

1212
def has_one_to_one?(association)

spec/support/background_job_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def execute_all_jobs(expected_successes:, expected_failures:, jobs_to_execute: 1
1212
successes, failures = Delayed::Worker.new.work_off(jobs_to_execute)
1313
failure_message = "Expected #{expected_successes} successful and #{expected_failures} failed jobs, got #{successes} successful and #{failures} failed jobs."
1414
fail_summaries = Delayed::Job.exclude(failed_at: nil).map { |j| "Handler: #{j.handler}, LastError: #{j.last_error}" }
15-
failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.count > 0
15+
failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.any?
1616
expect([successes, failures]).to eq([expected_successes, expected_failures]), failure_message
1717

1818
VCAP::CloudController::SecurityContext.set(saved_user, saved_token, saved_auth_token)

0 commit comments

Comments
 (0)