From 9270fe9be196f53263e40e6f3a372ff670259ec7 Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Sat, 4 Oct 2025 11:06:47 -0700 Subject: [PATCH 1/5] Use PredicatePrefix since PredicateName is deprecated --- .rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 98d12ff8b8d..82ed17f97d5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -129,7 +129,7 @@ Naming/HeredocDelimiterNaming: # ForbiddenPrefixes: is_, has_, have_ # AllowedMethods: is_a? # MethodDefinitionMacros: define_method, define_singleton_method -Naming/PredicateName: +Naming/PredicatePrefix: Enabled: false # Offense count: 862 From 83881622dc5e4c2583a465222009657f71a5eabc Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Sat, 4 Oct 2025 11:11:34 -0700 Subject: [PATCH 2/5] Rubocops that didn't need code changes --- .rubocop_cc.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index 2c9b88101d4..efe410fc782 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -143,6 +143,8 @@ Rails/SkipsModelValidations: # We don`t want any model at all in migrations and - spec/migrations/**/* #### ENABLED SECTION +Gemspec/AttributeAssignment: + Enabled: true Gemspec/DeprecatedAttributeAssignment: Enabled: true Gemspec/DevelopmentDependencies: @@ -239,8 +241,12 @@ Lint/UnexpectedBlockArity: Enabled: true Lint/UnmodifiedReduceAccumulator: Enabled: true +Lint/UselessDefaultValueArgument: + Enabled: true Lint/UselessDefined: Enabled: true +Lint/UselessOr: + Enabled: true Lint/UselessRescue: Enabled: true Lint/UselessRuby2Keywords: @@ -259,6 +265,8 @@ Style/ArgumentsForwarding: Enabled: true Style/ArrayIntersect: Enabled: true +Style/ArrayIntersectWithSingleElement: + Enabled: true Style/BitwisePredicate: Enabled: true Style/CollectionCompact: @@ -281,6 +289,8 @@ Style/DocumentDynamicEvalDefinition: Enabled: true Style/EmptyHeredoc: Enabled: true +Style/EmptyStringInsideInterpolation: + Enabled: true Style/EndlessMethod: Enabled: true Style/EnvHome: @@ -349,6 +359,8 @@ Style/RedundantArgument: Enabled: true Style/RedundantArrayConstructor: Enabled: true +Style/RedundantArrayFlatten: + Enabled: true Style/RedundantConstantBase: Enabled: true Style/RedundantCurrentDirectoryInPath: @@ -425,6 +437,8 @@ Rails/ExpandedDateRange: Enabled: true Rails/FindById: Enabled: true +Rails/FindByOrAssignmentMemoization: + Enabled: true Rails/FreezeTime: Enabled: true Rails/I18nLazyLookup: @@ -447,6 +461,8 @@ Rails/MultipleRoutePaths: Enabled: true Rails/NegateInclude: Enabled: true +Rails/OrderArguments: + Enabled: true Rails/Pluck: Enabled: true Rails/PluckInWhere: From 9d6e5245fb118bdb73b3fc5a9be5525482d1b610 Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Sat, 4 Oct 2025 13:03:14 -0700 Subject: [PATCH 3/5] Enable EmptyLinesAfterModuleInclusion --- .rubocop_cc.yml | 2 ++ app/actions/services/service_instance_read.rb | 1 + app/messages/service_broker_create_message.rb | 1 + app/models/runtime/app_model.rb | 1 + app/models/runtime/isolation_segment_model.rb | 1 + app/models/runtime/task_model.rb | 1 + app/presenters/v3/domain_presenter.rb | 1 + config/initializers/honeycomb.rb | 1 + lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb | 1 + lib/cloud_controller/diego/buildpack/task_action_builder.rb | 1 + lib/cloud_controller/diego/cnb/desired_lrp_builder.rb | 1 + lib/cloud_controller/diego/reporters/instances_reporter.rb | 1 + .../broker_api_compatibility/broker_api_v2.14_spec.rb | 1 + .../broker_api_compatibility/broker_api_v2.8_spec.rb | 1 + .../broker_api_compatibility/broker_api_versions_spec.rb | 4 ++-- spec/messages/nested_message_validator_spec.rb | 1 + spec/unit/lib/cloud_controller/encryptor_spec.rb | 1 + .../unit/messages/validators/authentication_validator_spec.rb | 1 + spec/unit/messages/validators/metadata_validator_spec.rb | 1 + .../messages/validators/security_group_rule_validator_spec.rb | 1 + spec/unit/messages/validators/url_validator_spec.rb | 1 + 21 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index efe410fc782..247abab2a57 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -151,6 +151,8 @@ Gemspec/DevelopmentDependencies: Enabled: true Gemspec/RequireMFA: Enabled: true +Layout/EmptyLinesAfterModuleInclusion: + Enabled: true Layout/LineContinuationLeadingSpace: Enabled: true Layout/LineContinuationSpacing: diff --git a/app/actions/services/service_instance_read.rb b/app/actions/services/service_instance_read.rb index d117bd02b6a..ae243c504a0 100644 --- a/app/actions/services/service_instance_read.rb +++ b/app/actions/services/service_instance_read.rb @@ -3,6 +3,7 @@ module VCAP::CloudController class ServiceInstanceRead include VCAP::CloudController::LockCheck + class NotSupportedError < ::StandardError end diff --git a/app/messages/service_broker_create_message.rb b/app/messages/service_broker_create_message.rb index 7340109216d..3eab97121bc 100644 --- a/app/messages/service_broker_create_message.rb +++ b/app/messages/service_broker_create_message.rb @@ -9,6 +9,7 @@ module VCAP::CloudController class ServiceBrokerCreateMessage < MetadataBaseMessage include AuthenticationMessageMixin + register_allowed_keys %i[name url authentication relationships] def self.relationships_requested? diff --git a/app/models/runtime/app_model.rb b/app/models/runtime/app_model.rb index bdb1dd7282a..b47733f7fb3 100644 --- a/app/models/runtime/app_model.rb +++ b/app/models/runtime/app_model.rb @@ -6,6 +6,7 @@ module VCAP::CloudController class AppModel < Sequel::Model(:apps) include Serializer + APP_NAME_REGEX = /\A[[:alnum:][:punct:][:print:]]+\Z/ DEFAULT_CONTAINER_USER = 'vcap'.freeze DEFAULT_DOCKER_CONTAINER_USER = 'root'.freeze diff --git a/app/models/runtime/isolation_segment_model.rb b/app/models/runtime/isolation_segment_model.rb index 7aac239a6ff..b66447b2c4e 100644 --- a/app/models/runtime/isolation_segment_model.rb +++ b/app/models/runtime/isolation_segment_model.rb @@ -3,6 +3,7 @@ class IsolationSegmentModel < Sequel::Model(:isolation_segments) SHARED_ISOLATION_SEGMENT_GUID = '933b4c58-120b-499a-b85d-4b6fc9e2903b'.freeze include Serializer + ISOLATION_SEGMENT_MODEL_REGEX = /\A[[:print:]]+\Z/ one_to_many :spaces, key: :isolation_segment_guid, primary_key: :guid diff --git a/app/models/runtime/task_model.rb b/app/models/runtime/task_model.rb index d21f3c13368..bad22c00eef 100644 --- a/app/models/runtime/task_model.rb +++ b/app/models/runtime/task_model.rb @@ -1,6 +1,7 @@ module VCAP::CloudController class TaskModel < Sequel::Model(:tasks) include Serializer + TASK_NAME_REGEX = /\A[[:alnum:][:punct:][:print:]]+\Z/ TASK_STATES = [ SUCCEEDED_STATE = 'SUCCEEDED'.freeze, diff --git a/app/presenters/v3/domain_presenter.rb b/app/presenters/v3/domain_presenter.rb index d1614d2113a..9ffa51fa951 100644 --- a/app/presenters/v3/domain_presenter.rb +++ b/app/presenters/v3/domain_presenter.rb @@ -5,6 +5,7 @@ module VCAP::CloudController::Presenters::V3 class DomainPresenter < BasePresenter include VCAP::CloudController::Presenters::Mixins::MetadataPresentationHelpers + def initialize( resource, show_secrets: false, diff --git a/config/initializers/honeycomb.rb b/config/initializers/honeycomb.rb index 73f3be87656..8a82a507336 100644 --- a/config/initializers/honeycomb.rb +++ b/config/initializers/honeycomb.rb @@ -16,6 +16,7 @@ def self.honeycomb(cc_config) class CustomSampler extend Honeycomb::DeterministicSampler + def self.sample(fields) sample_rate = 1 # Remove this if you want a closer look at our DB calls diff --git a/lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb b/lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb index 9cd5e72fa74..b1337fc5f32 100644 --- a/lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb +++ b/lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb @@ -3,6 +3,7 @@ module Diego module Buildpack class DesiredLrpBuilder include ::Diego::ActionBuilder + class InvalidStack < StandardError; end attr_reader :start_command, :action_user diff --git a/lib/cloud_controller/diego/buildpack/task_action_builder.rb b/lib/cloud_controller/diego/buildpack/task_action_builder.rb index 99f7731b088..1331b838543 100644 --- a/lib/cloud_controller/diego/buildpack/task_action_builder.rb +++ b/lib/cloud_controller/diego/buildpack/task_action_builder.rb @@ -7,6 +7,7 @@ module Diego module Buildpack class TaskActionBuilder include ::Diego::ActionBuilder + class InvalidStack < StandardError; end def initialize(config, task, lifecycle_data, run_user, launcher_args, prefix) diff --git a/lib/cloud_controller/diego/cnb/desired_lrp_builder.rb b/lib/cloud_controller/diego/cnb/desired_lrp_builder.rb index 6646db49193..1c81ce430ce 100644 --- a/lib/cloud_controller/diego/cnb/desired_lrp_builder.rb +++ b/lib/cloud_controller/diego/cnb/desired_lrp_builder.rb @@ -3,6 +3,7 @@ module Diego module CNB class DesiredLrpBuilder include ::Diego::ActionBuilder + class InvalidStack < StandardError; end attr_reader :start_command, :action_user diff --git a/lib/cloud_controller/diego/reporters/instances_reporter.rb b/lib/cloud_controller/diego/reporters/instances_reporter.rb index 105c7fed1f8..7874e720d1c 100644 --- a/lib/cloud_controller/diego/reporters/instances_reporter.rb +++ b/lib/cloud_controller/diego/reporters/instances_reporter.rb @@ -6,6 +6,7 @@ module VCAP::CloudController module Diego class InstancesReporter include ReporterMixins + InstanceCountSummary = Struct.new(:starting_instances_count, :routable_instances_count, :healthy_instances_count, :unhealthy_instances_count) HEALTHY_STATES = [VCAP::CloudController::Diego::LRP_RUNNING, VCAP::CloudController::Diego::LRP_STARTING].freeze UNKNOWN_INSTANCE_COUNT = -1 diff --git a/spec/acceptance/broker_api_compatibility/broker_api_v2.14_spec.rb b/spec/acceptance/broker_api_compatibility/broker_api_v2.14_spec.rb index ce28136ff0e..f97c0143955 100644 --- a/spec/acceptance/broker_api_compatibility/broker_api_v2.14_spec.rb +++ b/spec/acceptance/broker_api_compatibility/broker_api_v2.14_spec.rb @@ -3,6 +3,7 @@ RSpec.describe 'Service Broker API integration' do describe 'v2.14' do include VCAP::CloudController::BrokerApiHelper + let(:catalog) { default_catalog } before do diff --git a/spec/acceptance/broker_api_compatibility/broker_api_v2.8_spec.rb b/spec/acceptance/broker_api_compatibility/broker_api_v2.8_spec.rb index 6854969a6bd..960f10f821f 100644 --- a/spec/acceptance/broker_api_compatibility/broker_api_v2.8_spec.rb +++ b/spec/acceptance/broker_api_compatibility/broker_api_v2.8_spec.rb @@ -3,6 +3,7 @@ RSpec.describe 'Service Broker API integration' do describe 'v2.8' do include VCAP::CloudController::BrokerApiHelper + let(:route) { VCAP::CloudController::Route.make(space: @space) } let(:catalog) { default_catalog(requires: ['route_forwarding']) } let(:service_broker_bind_request) { %r{.*/v2/service_instances/#{@service_instance_guid}/service_bindings/#{guid_pattern}} } diff --git a/spec/acceptance/broker_api_compatibility/broker_api_versions_spec.rb b/spec/acceptance/broker_api_compatibility/broker_api_versions_spec.rb index d08494807dd..29983978f05 100644 --- a/spec/acceptance/broker_api_compatibility/broker_api_versions_spec.rb +++ b/spec/acceptance/broker_api_compatibility/broker_api_versions_spec.rb @@ -11,13 +11,13 @@ 'broker_api_v2.5_spec.rb' => '4cbc9df341ba86c2f1791b1a4870547c', 'broker_api_v2.6_spec.rb' => 'a1608878f601819c90b44be5f317ec44', 'broker_api_v2.7_spec.rb' => '2160e3d4985039f8fd2881106c7226ae', - 'broker_api_v2.8_spec.rb' => '2b1b662b4874f5bac4481de7cf15b363', + 'broker_api_v2.8_spec.rb' => '4cf48cbdd3db911c2c3a648ecc0475b8', 'broker_api_v2.9_spec.rb' => '002089c49e4c2db32689be56d48d4a45', 'broker_api_v2.10_spec.rb' => '2668e6821e9b45ab6d7c7e9eca9deb68', 'broker_api_v2.11_spec.rb' => '99e61dc50ceb635b09b3bd16901a4fa6', 'broker_api_v2.12_spec.rb' => '6be5f9646bf885498dd88c090fbed7af', 'broker_api_v2.13_spec.rb' => 'b8423b9f28e68adbc3c767b2185561c5', - 'broker_api_v2.14_spec.rb' => '62a84db32d01bedd0b20f37ebfcb17a0', + 'broker_api_v2.14_spec.rb' => '73b5de4f83d280d959eb9844c19a3018', 'broker_api_v2.15_spec.rb' => 'c8c910e903636d1a82e5a77fcdc1fbab' } end diff --git a/spec/messages/nested_message_validator_spec.rb b/spec/messages/nested_message_validator_spec.rb index da4c91c7783..be5ab2b1c65 100644 --- a/spec/messages/nested_message_validator_spec.rb +++ b/spec/messages/nested_message_validator_spec.rb @@ -23,6 +23,7 @@ def error_key class SampleActiveModel include ActiveModel::Model + validates_with CompleteValidator attr_accessor :data end diff --git a/spec/unit/lib/cloud_controller/encryptor_spec.rb b/spec/unit/lib/cloud_controller/encryptor_spec.rb index 6f7f2bb9122..1e4fea99aa9 100644 --- a/spec/unit/lib/cloud_controller/encryptor_spec.rb +++ b/spec/unit/lib/cloud_controller/encryptor_spec.rb @@ -203,6 +203,7 @@ module VCAP::CloudController let(:base_class) do Class.new do include VCAP::CloudController::Encryptor::FieldEncryptor + def self.columns raise '.columns: not implemented' end diff --git a/spec/unit/messages/validators/authentication_validator_spec.rb b/spec/unit/messages/validators/authentication_validator_spec.rb index 2a4952ada6f..de6a2a5d477 100644 --- a/spec/unit/messages/validators/authentication_validator_spec.rb +++ b/spec/unit/messages/validators/authentication_validator_spec.rb @@ -6,6 +6,7 @@ module VCAP::CloudController::Validators let(:class_with_authentication) do Class.new do include ActiveModel::Model + validates_with AuthenticationValidator attr_accessor :authentication diff --git a/spec/unit/messages/validators/metadata_validator_spec.rb b/spec/unit/messages/validators/metadata_validator_spec.rb index b4f274e42ca..25a41e55a18 100644 --- a/spec/unit/messages/validators/metadata_validator_spec.rb +++ b/spec/unit/messages/validators/metadata_validator_spec.rb @@ -6,6 +6,7 @@ module VCAP::CloudController::Validators let(:class_with_metadata) do Class.new do include ActiveModel::Model + validates_with MetadataValidator attr_accessor :metadata diff --git a/spec/unit/messages/validators/security_group_rule_validator_spec.rb b/spec/unit/messages/validators/security_group_rule_validator_spec.rb index 40f092d5495..9ca99b78edd 100644 --- a/spec/unit/messages/validators/security_group_rule_validator_spec.rb +++ b/spec/unit/messages/validators/security_group_rule_validator_spec.rb @@ -6,6 +6,7 @@ module VCAP::CloudController::Validators let(:class_with_rules) do Class.new do include ActiveModel::Model + validates_with RulesValidator def self.name diff --git a/spec/unit/messages/validators/url_validator_spec.rb b/spec/unit/messages/validators/url_validator_spec.rb index db5f0add6c2..c6521ec0f6d 100644 --- a/spec/unit/messages/validators/url_validator_spec.rb +++ b/spec/unit/messages/validators/url_validator_spec.rb @@ -6,6 +6,7 @@ module VCAP::CloudController::Validators let(:class_with_url) do Class.new do include ActiveModel::Model + validates_with UrlValidator attr_accessor :url From 3e1ffbca255bc7eaf4595e0749418614a57e1450 Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Sat, 4 Oct 2025 16:04:59 -0700 Subject: [PATCH 4/5] Enable CollectionQuerying - had to use -A on rubocop to autofix --- .rubocop_cc.yml | 2 ++ app/access/organization_access.rb | 10 +++++----- app/jobs/runtime/failed_jobs_cleanup.rb | 2 +- .../20161005205815_fix_droplets_process_types_json.rb | 2 +- ...0231205143526_remove_deployments_with_degenerate.rb | 2 +- .../diego/docker/staging_action_builder.rb | 2 +- lib/cloud_controller/errands/rotate_database_key.rb | 2 +- lib/cloud_controller/seeds.rb | 2 +- lib/sequel_plugins/vcap_relations.rb | 2 +- spec/support/background_job_helpers.rb | 2 +- .../runtime/app_summaries_controller_spec.rb | 2 +- .../repositories/app_usage_event_repository_spec.rb | 2 +- 12 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index 247abab2a57..9e019dce42f 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -271,6 +271,8 @@ Style/ArrayIntersectWithSingleElement: Enabled: true Style/BitwisePredicate: Enabled: true +Style/CollectionQuerying: + Enabled: true Style/CollectionCompact: Enabled: true Style/CombinableDefined: diff --git a/app/access/organization_access.rb b/app/access/organization_access.rb index 4be64f39cc5..7c3eea18eec 100644 --- a/app/access/organization_access.rb +++ b/app/access/organization_access.rb @@ -88,23 +88,23 @@ def validate!(org, params) end def validate_remove_billing_manager_by_guid!(org) - return if org.billing_managers_dataset.count > 1 + return if org.billing_managers_dataset.many? raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') end def validate_remove_manager_by_guid!(org) - return if org.managers_dataset.count > 1 + return if org.managers_dataset.many? raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') end def validate_remove_user_by_guid!(org, user_guid) - raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.count == 1 && org.managers.first.guid == user_guid + raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.one? && org.managers.first.guid == user_guid - raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.count == 1 && org.billing_managers.first.guid == user_guid + raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.one? && org.billing_managers.first.guid == user_guid - return unless org.users_dataset.count == 1 && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1 + return unless org.users_dataset.one? && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1 raise CloudController::Errors::ApiError.new_from_details('LastUserInOrg') end diff --git a/app/jobs/runtime/failed_jobs_cleanup.rb b/app/jobs/runtime/failed_jobs_cleanup.rb index 6812677c83c..1aa4443f54f 100644 --- a/app/jobs/runtime/failed_jobs_cleanup.rb +++ b/app/jobs/runtime/failed_jobs_cleanup.rb @@ -26,7 +26,7 @@ def perform orphaned_delayed_jobs = Delayed::Job. where(Sequel.lit("run_at < CURRENT_TIMESTAMP - INTERVAL '?' DAY", force_delete_after)) - unless orphaned_delayed_jobs.count.zero? + unless orphaned_delayed_jobs.none? logger.info("Deleting #{orphaned_delayed_jobs.count} orphaned Delayed Jobs older than #{force_delete_after} days") orphaned_delayed_jobs.delete diff --git a/db/migrations/20161005205815_fix_droplets_process_types_json.rb b/db/migrations/20161005205815_fix_droplets_process_types_json.rb index 6e22bcb2b71..955750f96b4 100644 --- a/db/migrations/20161005205815_fix_droplets_process_types_json.rb +++ b/db/migrations/20161005205815_fix_droplets_process_types_json.rb @@ -12,7 +12,7 @@ def add_command(command, id) end def flush - if @batched_commands.count > 0 + if @batched_commands.any? cases = [] ids = [] id_place_holders = [] diff --git a/db/migrations/20231205143526_remove_deployments_with_degenerate.rb b/db/migrations/20231205143526_remove_deployments_with_degenerate.rb index 44ce49b2a2a..3aa860c8d46 100644 --- a/db/migrations/20231205143526_remove_deployments_with_degenerate.rb +++ b/db/migrations/20231205143526_remove_deployments_with_degenerate.rb @@ -2,7 +2,7 @@ up do degenerate_records = self[:deployments].where(status_reason: 'DEGENERATE') - if degenerate_records.count > 0 + if degenerate_records.any? guids_dataset = degenerate_records.select(:guid) self[:deployment_processes].where(deployment_guid: guids_dataset).delete self[:deployment_labels].where(resource_guid: guids_dataset).delete diff --git a/lib/cloud_controller/diego/docker/staging_action_builder.rb b/lib/cloud_controller/diego/docker/staging_action_builder.rb index c4c259899b2..2dca0dacffe 100644 --- a/lib/cloud_controller/diego/docker/staging_action_builder.rb +++ b/lib/cloud_controller/diego/docker/staging_action_builder.rb @@ -17,7 +17,7 @@ def action "-dockerRef=#{staging_details.package.image}" ] - if config.get(:diego, :insecure_docker_registry_list).count > 0 + if config.get(:diego, :insecure_docker_registry_list).any? insecure_registries = "-insecureDockerRegistries=#{config.get(:diego, :insecure_docker_registry_list).join(',')}" run_args << insecure_registries end diff --git a/lib/cloud_controller/errands/rotate_database_key.rb b/lib/cloud_controller/errands/rotate_database_key.rb index 126a3655d1f..01c704bd403 100644 --- a/lib/cloud_controller/errands/rotate_database_key.rb +++ b/lib/cloud_controller/errands/rotate_database_key.rb @@ -32,7 +32,7 @@ def rotate_for_class(klass, batch_size) rows = rows_needing_rotation. limit(batch_size). all - break if rows.count == 0 + break if rows.none? klass.instance_exec do @allow_manual_timestamp_update = true diff --git a/lib/cloud_controller/seeds.rb b/lib/cloud_controller/seeds.rb index 9b6b3b3f0d3..5468e7db507 100644 --- a/lib/cloud_controller/seeds.rb +++ b/lib/cloud_controller/seeds.rb @@ -124,7 +124,7 @@ def find_routing_guid(domain) end def create_seed_security_groups(config) - return unless config.get(:security_group_definitions) && SecurityGroup.count == 0 + return unless config.get(:security_group_definitions) && SecurityGroup.none? config.get(:security_group_definitions).each do |security_group| seed_security_group = security_group.dup diff --git a/lib/sequel_plugins/vcap_relations.rb b/lib/sequel_plugins/vcap_relations.rb index d2e0f2ac513..f38354fb812 100644 --- a/lib/sequel_plugins/vcap_relations.rb +++ b/lib/sequel_plugins/vcap_relations.rb @@ -6,7 +6,7 @@ def self.apply(model) module InstanceMethods def has_one_to_many?(association) - association_type(association) == :one_to_many && send(association).count > 0 + association_type(association) == :one_to_many && send(association).any? end def has_one_to_one?(association) diff --git a/spec/support/background_job_helpers.rb b/spec/support/background_job_helpers.rb index 7e90edc50b5..084cf65e8ff 100644 --- a/spec/support/background_job_helpers.rb +++ b/spec/support/background_job_helpers.rb @@ -12,7 +12,7 @@ def execute_all_jobs(expected_successes:, expected_failures:, jobs_to_execute: 1 successes, failures = Delayed::Worker.new.work_off(jobs_to_execute) failure_message = "Expected #{expected_successes} successful and #{expected_failures} failed jobs, got #{successes} successful and #{failures} failed jobs." fail_summaries = Delayed::Job.exclude(failed_at: nil).map { |j| "Handler: #{j.handler}, LastError: #{j.last_error}" } - failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.count > 0 + failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.any? expect([successes, failures]).to eq([expected_successes, expected_failures]), failure_message VCAP::CloudController::SecurityContext.set(saved_user, saved_token, saved_auth_token) diff --git a/spec/unit/controllers/runtime/app_summaries_controller_spec.rb b/spec/unit/controllers/runtime/app_summaries_controller_spec.rb index f010e2e3b16..f1063e7790d 100644 --- a/spec/unit/controllers/runtime/app_summaries_controller_spec.rb +++ b/spec/unit/controllers/runtime/app_summaries_controller_spec.rb @@ -95,7 +95,7 @@ module VCAP::CloudController it 'contains list of both private domains and shared domains' do domains = @process.space.organization.private_domains - expect(domains.count > 0).to be(true) + expect(domains.any?).to be(true) private_domains = domains.collect do |domain| { 'guid' => domain.guid, diff --git a/spec/unit/repositories/app_usage_event_repository_spec.rb b/spec/unit/repositories/app_usage_event_repository_spec.rb index 02a3307a626..1b3e05c8d42 100644 --- a/spec/unit/repositories/app_usage_event_repository_spec.rb +++ b/spec/unit/repositories/app_usage_event_repository_spec.rb @@ -542,7 +542,7 @@ module Repositories started_app_count = ProcessModel.where(state: 'STARTED').count - expect(AppUsageEvent.count > 1).to be true + expect(AppUsageEvent.many?).to be true expect do repository.purge_and_reseed_started_apps! end.to change(AppUsageEvent, :count).to(started_app_count) From 1f02e20181fed2036d8c77ab19c063f1fb0c1fc2 Mon Sep 17 00:00:00 2001 From: "M. Oleske" Date: Wed, 8 Oct 2025 19:44:44 -0700 Subject: [PATCH 5/5] Revert "Enable CollectionQuerying" This reverts commit 3e1ffbca255bc7eaf4595e0749418614a57e1450. --- .rubocop_cc.yml | 2 -- app/access/organization_access.rb | 10 +++++----- app/jobs/runtime/failed_jobs_cleanup.rb | 2 +- .../20161005205815_fix_droplets_process_types_json.rb | 2 +- ...0231205143526_remove_deployments_with_degenerate.rb | 2 +- .../diego/docker/staging_action_builder.rb | 2 +- lib/cloud_controller/errands/rotate_database_key.rb | 2 +- lib/cloud_controller/seeds.rb | 2 +- lib/sequel_plugins/vcap_relations.rb | 2 +- spec/support/background_job_helpers.rb | 2 +- .../runtime/app_summaries_controller_spec.rb | 2 +- .../repositories/app_usage_event_repository_spec.rb | 2 +- 12 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index 9e019dce42f..247abab2a57 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -271,8 +271,6 @@ Style/ArrayIntersectWithSingleElement: Enabled: true Style/BitwisePredicate: Enabled: true -Style/CollectionQuerying: - Enabled: true Style/CollectionCompact: Enabled: true Style/CombinableDefined: diff --git a/app/access/organization_access.rb b/app/access/organization_access.rb index 7c3eea18eec..4be64f39cc5 100644 --- a/app/access/organization_access.rb +++ b/app/access/organization_access.rb @@ -88,23 +88,23 @@ def validate!(org, params) end def validate_remove_billing_manager_by_guid!(org) - return if org.billing_managers_dataset.many? + return if org.billing_managers_dataset.count > 1 raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') end def validate_remove_manager_by_guid!(org) - return if org.managers_dataset.many? + return if org.managers_dataset.count > 1 raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') end def validate_remove_user_by_guid!(org, user_guid) - raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.one? && org.managers.first.guid == user_guid + raise CloudController::Errors::ApiError.new_from_details('LastManagerInOrg') if org.managers_dataset.count == 1 && org.managers.first.guid == user_guid - raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.one? && org.billing_managers.first.guid == user_guid + raise CloudController::Errors::ApiError.new_from_details('LastBillingManagerInOrg') if org.billing_managers_dataset.count == 1 && org.billing_managers.first.guid == user_guid - return unless org.users_dataset.one? && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1 + return unless org.users_dataset.count == 1 && org.users.first.guid == user_guid && org.managers_dataset.count <= 1 && org.billing_managers_dataset.count <= 1 raise CloudController::Errors::ApiError.new_from_details('LastUserInOrg') end diff --git a/app/jobs/runtime/failed_jobs_cleanup.rb b/app/jobs/runtime/failed_jobs_cleanup.rb index 1aa4443f54f..6812677c83c 100644 --- a/app/jobs/runtime/failed_jobs_cleanup.rb +++ b/app/jobs/runtime/failed_jobs_cleanup.rb @@ -26,7 +26,7 @@ def perform orphaned_delayed_jobs = Delayed::Job. where(Sequel.lit("run_at < CURRENT_TIMESTAMP - INTERVAL '?' DAY", force_delete_after)) - unless orphaned_delayed_jobs.none? + unless orphaned_delayed_jobs.count.zero? logger.info("Deleting #{orphaned_delayed_jobs.count} orphaned Delayed Jobs older than #{force_delete_after} days") orphaned_delayed_jobs.delete diff --git a/db/migrations/20161005205815_fix_droplets_process_types_json.rb b/db/migrations/20161005205815_fix_droplets_process_types_json.rb index 955750f96b4..6e22bcb2b71 100644 --- a/db/migrations/20161005205815_fix_droplets_process_types_json.rb +++ b/db/migrations/20161005205815_fix_droplets_process_types_json.rb @@ -12,7 +12,7 @@ def add_command(command, id) end def flush - if @batched_commands.any? + if @batched_commands.count > 0 cases = [] ids = [] id_place_holders = [] diff --git a/db/migrations/20231205143526_remove_deployments_with_degenerate.rb b/db/migrations/20231205143526_remove_deployments_with_degenerate.rb index 3aa860c8d46..44ce49b2a2a 100644 --- a/db/migrations/20231205143526_remove_deployments_with_degenerate.rb +++ b/db/migrations/20231205143526_remove_deployments_with_degenerate.rb @@ -2,7 +2,7 @@ up do degenerate_records = self[:deployments].where(status_reason: 'DEGENERATE') - if degenerate_records.any? + if degenerate_records.count > 0 guids_dataset = degenerate_records.select(:guid) self[:deployment_processes].where(deployment_guid: guids_dataset).delete self[:deployment_labels].where(resource_guid: guids_dataset).delete diff --git a/lib/cloud_controller/diego/docker/staging_action_builder.rb b/lib/cloud_controller/diego/docker/staging_action_builder.rb index 2dca0dacffe..c4c259899b2 100644 --- a/lib/cloud_controller/diego/docker/staging_action_builder.rb +++ b/lib/cloud_controller/diego/docker/staging_action_builder.rb @@ -17,7 +17,7 @@ def action "-dockerRef=#{staging_details.package.image}" ] - if config.get(:diego, :insecure_docker_registry_list).any? + if config.get(:diego, :insecure_docker_registry_list).count > 0 insecure_registries = "-insecureDockerRegistries=#{config.get(:diego, :insecure_docker_registry_list).join(',')}" run_args << insecure_registries end diff --git a/lib/cloud_controller/errands/rotate_database_key.rb b/lib/cloud_controller/errands/rotate_database_key.rb index 01c704bd403..126a3655d1f 100644 --- a/lib/cloud_controller/errands/rotate_database_key.rb +++ b/lib/cloud_controller/errands/rotate_database_key.rb @@ -32,7 +32,7 @@ def rotate_for_class(klass, batch_size) rows = rows_needing_rotation. limit(batch_size). all - break if rows.none? + break if rows.count == 0 klass.instance_exec do @allow_manual_timestamp_update = true diff --git a/lib/cloud_controller/seeds.rb b/lib/cloud_controller/seeds.rb index 5468e7db507..9b6b3b3f0d3 100644 --- a/lib/cloud_controller/seeds.rb +++ b/lib/cloud_controller/seeds.rb @@ -124,7 +124,7 @@ def find_routing_guid(domain) end def create_seed_security_groups(config) - return unless config.get(:security_group_definitions) && SecurityGroup.none? + return unless config.get(:security_group_definitions) && SecurityGroup.count == 0 config.get(:security_group_definitions).each do |security_group| seed_security_group = security_group.dup diff --git a/lib/sequel_plugins/vcap_relations.rb b/lib/sequel_plugins/vcap_relations.rb index f38354fb812..d2e0f2ac513 100644 --- a/lib/sequel_plugins/vcap_relations.rb +++ b/lib/sequel_plugins/vcap_relations.rb @@ -6,7 +6,7 @@ def self.apply(model) module InstanceMethods def has_one_to_many?(association) - association_type(association) == :one_to_many && send(association).any? + association_type(association) == :one_to_many && send(association).count > 0 end def has_one_to_one?(association) diff --git a/spec/support/background_job_helpers.rb b/spec/support/background_job_helpers.rb index 084cf65e8ff..7e90edc50b5 100644 --- a/spec/support/background_job_helpers.rb +++ b/spec/support/background_job_helpers.rb @@ -12,7 +12,7 @@ def execute_all_jobs(expected_successes:, expected_failures:, jobs_to_execute: 1 successes, failures = Delayed::Worker.new.work_off(jobs_to_execute) failure_message = "Expected #{expected_successes} successful and #{expected_failures} failed jobs, got #{successes} successful and #{failures} failed jobs." fail_summaries = Delayed::Job.exclude(failed_at: nil).map { |j| "Handler: #{j.handler}, LastError: #{j.last_error}" } - failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.any? + failure_message += " Failures: \n#{fail_summaries.join("\n")}" if fail_summaries.count > 0 expect([successes, failures]).to eq([expected_successes, expected_failures]), failure_message VCAP::CloudController::SecurityContext.set(saved_user, saved_token, saved_auth_token) diff --git a/spec/unit/controllers/runtime/app_summaries_controller_spec.rb b/spec/unit/controllers/runtime/app_summaries_controller_spec.rb index f1063e7790d..f010e2e3b16 100644 --- a/spec/unit/controllers/runtime/app_summaries_controller_spec.rb +++ b/spec/unit/controllers/runtime/app_summaries_controller_spec.rb @@ -95,7 +95,7 @@ module VCAP::CloudController it 'contains list of both private domains and shared domains' do domains = @process.space.organization.private_domains - expect(domains.any?).to be(true) + expect(domains.count > 0).to be(true) private_domains = domains.collect do |domain| { 'guid' => domain.guid, diff --git a/spec/unit/repositories/app_usage_event_repository_spec.rb b/spec/unit/repositories/app_usage_event_repository_spec.rb index 1b3e05c8d42..02a3307a626 100644 --- a/spec/unit/repositories/app_usage_event_repository_spec.rb +++ b/spec/unit/repositories/app_usage_event_repository_spec.rb @@ -542,7 +542,7 @@ module Repositories started_app_count = ProcessModel.where(state: 'STARTED').count - expect(AppUsageEvent.many?).to be true + expect(AppUsageEvent.count > 1).to be true expect do repository.purge_and_reseed_started_apps! end.to change(AppUsageEvent, :count).to(started_app_count)