Skip to content
Open
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
695 changes: 413 additions & 282 deletions .rubocop_cc.yml

Large diffs are not rendered by default.

206 changes: 119 additions & 87 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/actions/app_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def validate_stack_state(app, message, lifecycle)
stack = Stack.find(name: message.buildpack_data.stack)
return [] unless stack

if app.builds_dataset.count.zero?
if app.builds_dataset.empty?
StackStateValidator.validate_for_new_app!(stack)
else
StackStateValidator.validate_for_restaging!(stack)
Expand Down
2 changes: 1 addition & 1 deletion app/actions/build_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def validate_stack_state!(lifecycle, app)
end

def first_build_for_app?(app)
app.builds_dataset.count.zero?
app.builds_dataset.empty?
end
end
end
2 changes: 1 addition & 1 deletion app/actions/v2/app_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def validate_stack_state(app, request_attrs)
stack = Stack.find(guid: request_attrs['stack_guid'])
return unless stack

stack_warnings = if app.builds_dataset.count.zero?
stack_warnings = if app.builds_dataset.empty?
StackStateValidator.validate_for_new_app!(stack)
else
StackStateValidator.validate_for_restaging!(stack)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/runtime/failed_jobs_cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.empty?
logger.info("Deleting #{orphaned_delayed_jobs.count} orphaned Delayed Jobs older than #{force_delete_after} days")

orphaned_delayed_jobs.delete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Sequel.migration do
up do
alter_table :service_instances do
# rubocop:disable Migration/IncludeStringSize
set_column_type :syslog_drain_url, String, text: true
# rubocop:enable Migration/IncludeStringSize
end
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Sequel.migration do
up do
alter_table :service_bindings do
# rubocop:disable Migration/IncludeStringSize
set_column_type :syslog_drain_url, String, text: true
# rubocop:enable Migration/IncludeStringSize
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
# older brokers that may have long descriptions. Here we are disabling
# rubocop from checking the string size.
alter_table :services do
# rubocop:disable Migration/IncludeStringSize
set_column_type :description, String, text: true
# rubocop:enable Migration/IncludeStringSize
end

alter_table :service_plans do
# rubocop:disable Migration/IncludeStringSize
set_column_type :description, String, text: true
# rubocop:enable Migration/IncludeStringSize
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
# field type here.
# For the guid we have control, so we explicitly set a limit.

# rubocop:disable Migration/IncludeStringSize
add_column :service_usage_events, :service_broker_name, String, null: true
# rubocop:enable Migration/IncludeStringSize
add_column :service_usage_events, :service_broker_guid, String, null: true, size: 255
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Sequel.migration do
change do
alter_table(:revisions) do
# rubocop:disable Migration/IncludeStringSize
add_column :description, String, text: true, default: 'N/A', null: false
# rubocop:enable Migration/IncludeStringSize
end
end
end
2 changes: 0 additions & 2 deletions db/migrations/20190930225152_add_sidecars_to_droplets.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Sequel.migration do
change do
alter_table :droplets do
# rubocop:disable Migration/IncludeStringSize
add_column :sidecars, String, text: true, default: nil
# rubocop:enable Migration/IncludeStringSize
end
end
end
2 changes: 1 addition & 1 deletion lib/cloud_controller/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.empty?

config.get(:security_group_definitions).each do |security_group|
seed_security_group = security_group.dup
Expand Down
18 changes: 7 additions & 11 deletions lib/locket/lock_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Error < StandardError
end

def initialize(key:, owner:, host:, port:, client_ca_path:, client_cert_path:, client_key_path:)
client_ca = File.open(client_ca_path).read
client_key = File.open(client_key_path).read
client_cert = File.open(client_cert_path).read
client_ca = File.read(client_ca_path)
client_key = File.read(client_key_path)
client_cert = File.read(client_cert_path)

@service = Models::Locket::Stub.new(
"#{host}:#{port}",
Expand All @@ -29,15 +29,11 @@ def start
loop do
begin
service.lock(build_lock_request)
if !@lock_acquired then
logger.info("Acquired lock '#{key}' for owner '#{owner}'")
end
logger.info("Acquired lock '#{key}' for owner '#{owner}'") unless @lock_acquired
@lock_acquired = true
failed = false
rescue GRPC::BadStatus => e
if !failed then
logger.info("Failed to acquire lock '#{key}' for owner '#{owner}': #{e.message}")
end
logger.info("Failed to acquire lock '#{key}' for owner '#{owner}': #{e.message}") unless failed
failed = true
@lock_acquired = false
end
Expand Down Expand Up @@ -65,9 +61,9 @@ def build_lock_request
resource: {
key: key,
owner: owner,
type_code: Models::TypeCode::LOCK,
type_code: Models::TypeCode::LOCK
},
ttl_in_seconds: 15,
ttl_in_seconds: 15
}
)
end
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 @@ -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)
Expand Down