Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ group :test do
gem 'rspec-its'
gem 'rspec-rails', '~> 8.0.4'
gem 'rspec-wait'
gem 'rubocop', '~> 1.88.1'
gem 'rubocop', '~> 1.88.2'
gem 'rubocop-capybara'
gem 'rubocop-factory_bot'
gem 'rubocop-rails', '~> 2.36'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ GEM
activesupport (>= 3.0.0)
mustache (~> 1.0, >= 0.99.4)
rspec (~> 3.0)
rubocop (1.88.1)
rubocop (1.88.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand Down Expand Up @@ -481,7 +481,7 @@ DEPENDENCIES
rspec-rails (~> 8.0.4)
rspec-wait
rspec_api_documentation (>= 6.1.0)
rubocop (~> 1.88.1)
rubocop (~> 1.88.2)
rubocop-capybara
rubocop-factory_bot
rubocop-rails (~> 2.36)
Expand Down
2 changes: 2 additions & 0 deletions app/actions/deployment_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ def enhanced_deployment_create_error(e, app)
org_error_msg = org_error_msg_1 + org_error_msg_2
error_message = e.message

# rubocop:disable Style/ArrayIntersect -- e.message is a String, not an Array
if space_quota_errors.any? { |substring| e.message.include?(substring) }
error_message += space_error_msg
elsif org_quota_errors.any? { |substring| e.message.include?(substring) }
error_message += org_error_msg
end
# rubocop:enable Style/ArrayIntersect

error = DeploymentCreate::Error.new(error_message)
error.set_backtrace(e.backtrace)
Expand Down
6 changes: 3 additions & 3 deletions app/actions/domain_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def create(message:, shared_organizations: [])
private

def validation_error!(message, error)
error!("The domain name \"#{message.name}\" is already in use") if error.errors.on(:name)&.any? { |e| [:unique].include?(e) }
error!("The domain name \"#{message.name}\" is already in use") if error.errors.on(:name)&.intersect?([:unique])

error!("The \"#{message.name}\" domain is reserved and cannot be used for org-scoped domains.") if error.errors.on(:name)&.any? { |e| [:reserved].include?(e) }
error!("The \"#{message.name}\" domain is reserved and cannot be used for org-scoped domains.") if error.errors.on(:name)&.intersect?([:reserved])

if error.errors.on(:organization)&.any? { |e| [:total_private_domains_exceeded].include?(e) }
if error.errors.on(:organization)&.intersect?([:total_private_domains_exceeded])
org = Organization.find(guid: message.organization_guid).name
error!("The number of private domains exceeds the quota for organization \"#{org}\"")
end
Expand Down
7 changes: 3 additions & 4 deletions app/actions/role_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ def create_organization_billing_manager(user, organization, role_type)
end

def space_validation_error!(type, error, user, space)
error!("User '#{user.presentation_name}' already has '#{type}' role in space '#{space.name}'.") if error.errors.on(%i[space_id user_id])&.any? { |e| [:unique].include?(e) }
error!("User '#{user.presentation_name}' already has '#{type}' role in space '#{space.name}'.") if error.errors.on(%i[space_id user_id])&.intersect?([:unique])

error!(error.message)
end

def organization_validation_error!(type, error, user, organization)
error!("User '#{user.presentation_name}' already has '#{type}' role in organization '#{organization.name}'.") if error.errors.on(%i[organization_id user_id])&.any? do |e|
[:unique].include?(e)
end
error!("User '#{user.presentation_name}' already has '#{type}' role in organization '#{organization.name}'.") if error.errors.on(%i[organization_id
user_id])&.intersect?([:unique])

error!(error.message)
end
Expand Down
6 changes: 2 additions & 4 deletions app/actions/user_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ def create(message:)
private

def validation_error!(message, error)
error!("User with guid '#{message.guid}' already exists.") if message.guid && error.errors.on(:guid)&.any? { |e| [:unique].include?(e) }
error!("User with guid '#{message.guid}' already exists.") if message.guid && error.errors.on(:guid)&.intersect?([:unique])

if !message.guid && error.errors.on(:guid)&.any? { |e| [:unique].include?(e) }
error!("User with username '#{message.username}' and origin '#{message.origin}' already exists.")
end
error!("User with username '#{message.username}' and origin '#{message.origin}' already exists.") if !message.guid && error.errors.on(:guid)&.intersect?([:unique])

error!(error.message)
end
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/include_binding_app_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module VCAP::CloudController
class IncludeBindingAppDecorator
class << self
def match?(include)
include&.any? { |i| %w[app].include?(i) }
include&.intersect?(%w[app])
end

def decorate(hash, bindings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module VCAP::CloudController
class IncludeBindingServiceInstanceDecorator
class << self
def match?(include)
include&.any? { |i| %w[service_instance].include?(i) }
include&.intersect?(%w[service_instance])
end

def decorate(hash, bindings)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/include_organization_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module VCAP::CloudController
class IncludeOrganizationDecorator
class << self
def match?(include)
include&.any? { |i| %w[org space.organization].include?(i) }
include&.intersect?(%w[org space.organization])
end

def decorate(hash, resources)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/include_route_domain_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module VCAP::CloudController
class IncludeRouteDomainDecorator
class << self
def match?(include)
include&.any? { |i| %w[domain].include?(i) }
include&.intersect?(%w[domain])
end

def decorate(hash, routes)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/include_space_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module VCAP::CloudController
class IncludeSpaceDecorator
class << self
def match?(include)
include&.any? { |i| %w[space space.organization].include?(i) }
include&.intersect?(%w[space space.organization])
end

def decorate(hash, resources)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/include_space_organization_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module VCAP::CloudController
class IncludeSpaceOrganizationDecorator
class << self
def match?(include)
include&.any? { |i| %w[org organization].include?(i) }
include&.intersect?(%w[org organization])
end

def decorate(hash, spaces)
Expand Down
2 changes: 1 addition & 1 deletion app/models/runtime/helpers/organization_role_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def around_save
yield
rescue Sequel::UniqueConstraintViolation => e
unique_indexes = %w[org_users_idx org_auditors_idx org_managers_idx org_billing_managers_idx]
raise e unless unique_indexes.any? { |pattern| e.message.include?(pattern) }
raise e unless unique_indexes.any? { |pattern| e.message.include?(pattern) } # rubocop:disable Style/ArrayIntersect -- e.message is a String, not an Array

errors.add(%i[organization_id user_id], :unique)
raise validation_failed_error
Expand Down
2 changes: 1 addition & 1 deletion app/models/runtime/helpers/space_role_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def around_save
yield
rescue Sequel::UniqueConstraintViolation => e
unique_indexes = %w[space_developers_idx space_auditors_idx space_managers_idx spaces_supporters_user_space_index]
raise e unless unique_indexes.any? { |pattern| e.message.include?(pattern) }
raise e unless unique_indexes.any? { |pattern| e.message.include?(pattern) } # rubocop:disable Style/ArrayIntersect -- e.message is a String, not an Array

errors.add(%i[space_id user_id], :unique)
raise validation_failed_error
Expand Down
2 changes: 1 addition & 1 deletion lib/sequel_plugins/vcap_relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def many_to_many(name, opts={})
end
rescue Sequel::UniqueConstraintViolation => e
# ignore the error and rollback the inner transaction
raise Sequel::Rollback if opts[:ignored_unique_constraint_violation_errors]&.any? { |pattern| e.message.include?(pattern) }
raise Sequel::Rollback if opts[:ignored_unique_constraint_violation_errors]&.any? { |pattern| e.message.include?(pattern) } # rubocop:disable Style/ArrayIntersect -- e.message is a String, not an Array

raise e
end
Expand Down
2 changes: 1 addition & 1 deletion middleware/below_min_cli_warning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def call(env)

included_endpoints = %w[/v3/spaces /v3/organizations /v2/spaces /v2/organizations]

if included_endpoints.any? { |ep| env['REQUEST_PATH'].include?(ep) } && is_below_min_cli_version?(env['HTTP_USER_AGENT'])
if included_endpoints.any? { |ep| env['REQUEST_PATH'].include?(ep) } && is_below_min_cli_version?(env['HTTP_USER_AGENT']) # rubocop:disable Style/ArrayIntersect -- env['REQUEST_PATH'] is a String, not an Array
# Ensure existing warnings are appended by ',' (unicode %2C)
new_warning = env['X-Cf-Warnings'].nil? ? escaped_warning : "#{env['X-Cf-Warnings']}%2C#{escaped_warning}"
headers['X-Cf-Warnings'] = new_warning
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/actions/manifest_route_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module VCAP::CloudController
ManifestRouteUpdate.update(app.guid, message, user_audit_info)

routes = app.reload.routes
expect(routes.length).to eq(num_routes + 0)
expect(routes.length).to eq(num_routes)
expect(Route.count).to eq(num_maps + 1)

route = routes.first
Expand Down
Loading