Skip to content

Commit 2d5425a

Browse files
committed
Bump Rubocop to 0.48.1
- Disable AmbiguousBlockAssociation because it fails on our specs using `expect { foo }.to change { bar }` - Disable PercentLiteralDelimiters because it conflicts with our current style for string arrays using `()` instead of `[]` - Disable SymbolArray because it conflicts with our current style [finishes #145974963]
1 parent 6355836 commit 2d5425a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+183
-186
lines changed

.rubocop.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ AllCops:
1010
- vendor/**/*
1111
- lib/diego/bbs/models/**/*
1212

13+
Lint/AmbiguousBlockAssociation:
14+
Enabled: false
15+
1316
Lint/AmbiguousRegexpLiteral:
1417
Enabled: false
1518

16-
# enable me for #85546748
1719
Lint/HandleExceptions:
1820
Enabled: false
1921

@@ -39,6 +41,7 @@ Metrics/BlockLength:
3941
- spec/**/*
4042
- lib/cloud_controller/config.rb
4143
- config/routes.rb
44+
- lib/tasks/db.rake
4245
Max: 50
4346

4447
Metrics/ClassLength:
@@ -98,6 +101,10 @@ Style/DoubleNegation:
98101
Style/EachWithObject:
99102
Enabled: false
100103

104+
Style/FileName:
105+
Exclude:
106+
- Guardfile
107+
101108
Style/FormatString:
102109
EnforcedStyle: sprintf
103110

@@ -155,6 +162,9 @@ Style/NumericLiterals:
155162
Style/NumericPredicate:
156163
Enabled: false
157164

165+
Style/PercentLiteralDelimiters:
166+
Enabled: false
167+
158168
Style/PredicateName:
159169
Enabled: false
160170

@@ -182,6 +192,9 @@ Style/SpaceAroundEqualsInParameterDefault:
182192
Style/StructInheritance:
183193
Enabled: false
184194

195+
Style/SymbolArray:
196+
Enabled: false
197+
185198
Style/TernaryParentheses:
186199
Enabled: false
187200

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ GEM
336336
rspec-mocks (~> 3.4.0)
337337
rspec-support (~> 3.4.0)
338338
rspec-support (3.4.1)
339-
rubocop (0.47.1)
339+
rubocop (0.48.1)
340340
parser (>= 2.3.3.1, < 3.0)
341341
powerpack (~> 0.1)
342342
rainbow (>= 1.99.1, < 3.0)

Guardfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# cc Guardfile
22
# More info at https://github.com/guard/guard#readme
33

4-
guard 'rspec', :cli => '--color --format doc --fail-fast', :all_on_start => false, :all_after_pass => false do
4+
guard 'rspec', cli: '--color --format doc --fail-fast', all_on_start: false, all_after_pass: false do
55
watch(%r{^spec/.+_spec\.rb$})
6-
watch("lib/cloud_controller/api/app.rb") { "spec/api/legacy_apps_spec.rb" }
6+
watch('lib/cloud_controller/api/app.rb') { 'spec/api/legacy_apps_spec.rb' }
77
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
88
watch(%r{^lib/cloud_controller/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9-
watch('spec/spec_helper.rb') { "spec" }
9+
watch('spec/spec_helper.rb') { 'spec' }
1010

1111
# These don't match the exact same dir structure between lib and spec
12-
watch(%r{^lib/cloud_controller/legacy_api/(.+)\.rb$}) { |m| "spec/api/#{m[1]}_spec.rb" }
13-
watch(%r{^lib/eventmachine/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12+
watch(%r{^lib/cloud_controller/legacy_api/(.+)\.rb$}) { |m| "spec/api/#{m[1]}_spec.rb" }
13+
watch(%r{^lib/eventmachine/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
1414
end

app/actions/route_mapping_create.rb

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def add(message)
4646
end
4747

4848
route_mapping
49-
5049
rescue Sequel::ValidationFailed => e
5150
if e.errors && e.errors.on([:app_guid, :route_guid, :process_type, :app_port]) && e.errors.on([:app_guid, :route_guid, :process_type, :app_port]).include?(:unique)
5251
raise DuplicateRouteMapping.new(DUPLICATE_MESSAGE)

app/actions/services/service_key_create.rb

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def create(service_instance, key_attrs, arbitrary_parameters)
2828
orphan_mitigator.attempt_delete_key(service_key)
2929
raise e
3030
end
31-
3231
rescue => e
3332
errors << e
3433
end

app/actions/services/service_key_delete.rb

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def delete_service_binding(service_binding)
2121

2222
service_instance.client.unbind(service_binding)
2323
service_binding.destroy
24-
2524
rescue => e
2625
errors << e
2726
end

app/actions/v2/route_mapping_create.rb

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def add
5454
end
5555

5656
route_mapping
57-
5857
rescue Sequel::ValidationFailed => e
5958
if e.errors && e.errors.on([:app_guid, :route_guid, :process_type, :app_port]) && e.errors.on([:app_guid, :route_guid, :process_type, :app_port]).include?(:unique)
6059
raise DuplicateRouteMapping.new(DUPLICATE_MESSAGE)

app/controllers/base/base_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def v2_api?
146146
end
147147

148148
def unversioned_api?
149-
!(env['PATH_INFO'] =~ %r{\A/v\d})
149+
env['PATH_INFO'] !~ %r{\A/v\d}
150150
end
151151

152152
def recursive_delete?

app/controllers/runtime/route_mappings_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def create
4343
{ 'Location' => "#{self.class.path}/#{route_mapping.guid}" },
4444
object_renderer.render_json(self.class, route_mapping, @opts)
4545
]
46-
4746
rescue ::VCAP::CloudController::V2::RouteMappingCreate::DuplicateRouteMapping
4847
raise CloudController::Errors::ApiError.new_from_details('RouteMappingTaken', route_mapping_taken_message(request_attrs))
4948
rescue ::VCAP::CloudController::V2::RouteMappingCreate::UnavailableAppPort

app/controllers/services/service_bindings_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def create
5151
{ 'Location' => "#{self.class.path}/#{service_binding.guid}" },
5252
object_renderer.render_json(self.class, service_binding, @opts)
5353
]
54-
5554
rescue ServiceBindingCreate::ServiceInstanceNotBindable
5655
raise CloudController::Errors::ApiError.new_from_details('UnbindableService')
5756
rescue ServiceBindingCreate::VolumeMountServiceDisabled

app/controllers/v3/service_bindings_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def destroy
6060
ServiceBindingDelete.new(user_audit_info).single_delete_sync(binding)
6161

6262
head :no_content
63-
6463
rescue ServiceBindingDelete::FailedToDelete => e
6564
unprocessable!(e.message)
6665
end

app/jobs/v3/package_bits_copier.rb

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def perform
1919
CloudController::DependencyLocator.instance.package_blobstore.cp_file_between_keys(@src_package_guid, @dest_package_guid)
2020
checksums = { sha1: src_package.package_hash, sha256: src_package.sha256_checksum }
2121
dest_package.succeed_upload!(checksums)
22-
2322
rescue => e
2423
dest_package.fail_upload!("failed to copy - #{e.message}") if dest_package
2524
raise

app/models/runtime/feature_flag.rb

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def self.enabled?(feature_flag_name)
5050
feature_flag = FeatureFlag.find(name: feature_flag_name.to_s)
5151
return feature_flag.enabled if feature_flag
5252
DEFAULT_FLAGS.fetch(feature_flag_name)
53-
5453
rescue KeyError
5554
raise UndefinedFeatureFlagError.new "invalid key: #{feature_flag_name}"
5655
end

app/presenters/message_bus/service_binding_presenter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def to_hash
1717
def self.censor_volume_mounts(volume_mounts)
1818
return [] unless volume_mounts.is_a?(Array)
1919
volume_mounts.map do |mount_info|
20-
mount_info.reject { |k, _v| !WHITELISTED_VOLUME_FIELDS.include?(k) }
20+
mount_info.select { |k, _v| WHITELISTED_VOLUME_FIELDS.include?(k) }
2121
end
2222
end
2323

db/migrations/20141120182308_reprocess_diego_apps.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
def diego?(row)
99
decrypted = VCAP::CloudController::Encryptor.decrypt(row[:encrypted_environment_json], row[:salt])
1010
environment_json = JSON.parse(decrypted)
11-
!!(environment_json['DIEGO_RUN_BETA'] == 'true')
11+
!environment_json['DIEGO_RUN_BETA'] != 'true'
1212
end
1313
end

lib/cloud_controller/blobstore/retryable_blob.rb

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def local_path
4949
def with_retries(log_prefix, log_data)
5050
retries ||= num_retries
5151
yield
52-
5352
rescue *retryable_errors => e
5453
retries -= 1
5554

lib/cloud_controller/blobstore/retryable_client.rb

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def blob(key)
124124
def with_retries(log_prefix, log_data)
125125
retries ||= @num_retries
126126
yield
127-
128127
rescue *@retryable_errors => e
129128
retries -= 1
130129

lib/cloud_controller/diego/instances_reporter.rb

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def crashed_instances_for_app(process)
8787
}
8888
end
8989
crashed_instances
90-
9190
rescue => e
9291
raise e if e.is_a? CloudController::Errors::InstancesUnavailable
9392
logger.error('crashed_instances_for_app.error', error: e.to_s)

lib/cloud_controller/diego/processes_sync.rb

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def sync
5050
end
5151

5252
@workpool.drain
53-
5453
rescue CloudController::Errors::ApiError => e
5554
if e.name == 'RunnerInvalidRequest'
5655
logger.info('synced-invalid-desired-lrps', error: e.name, error_message: e.message)

lib/cloud_controller/diego/stager.rb

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def initialize(config)
77

88
def stage(staging_details)
99
send_stage_package_request(staging_details)
10-
1110
rescue CloudController::Errors::ApiError => e
1211
logger.error('stage.package', package_guid: staging_details.package.guid, staging_guid: staging_details.staging_guid, error: e)
1312
build = BuildModel.find(guid: staging_details.staging_guid)

lib/cloud_controller/diego/tps_instances_reporter.rb

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def crashed_instances_for_app(process)
8989
end
9090

9191
result
92-
9392
rescue CloudController::Errors::InstancesUnavailable => e
9493
raise e
9594
rescue => e

lib/cloud_controller/rest_controller/paginated_collection_renderer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def fetch_and_process_records(paginated_dataset, controller, inline_relations_de
101101
collection_transformer.transform(dataset_records, transform_opts) if collection_transformer
102102

103103
serialized_records = dataset_records.map { |obj| @serializer.serialize(controller, obj, opts, orphans) }
104-
serialized_records.select { |obj| !obj.nil? }
104+
serialized_records.reject(&:nil?)
105105
end
106106

107107
def default_visibility_filter

lib/cloud_controller/rule_validator.rb

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def self.validate_destination(destination)
4545
end
4646

4747
return true
48-
4948
rescue NetAddr::ValidationError
5049
return false
5150
end

lib/cloud_controller/security_context.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.missing_token?
4444
end
4545

4646
def self.valid_token?
47-
token && !(token == :invalid_token)
47+
token && token != :invalid_token
4848
end
4949

5050
def self.invalid_token?

lib/tasks/buildpacks.rake

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace :buildpacks do
2-
3-
desc "Install/Update buildpacks"
2+
desc 'Install/Update buildpacks'
43
task :install do
54
buildpacks = RakeConfig.config[:install_buildpacks]
65
BackgroundJobEnvironment.new(RakeConfig.config).setup_environment do

lib/tasks/clock.rake

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace :clock do
2-
desc "Start a recurring tasks"
2+
desc 'Start a recurring tasks'
33
task :start do
4-
require "cloud_controller/clock/scheduler"
4+
require 'cloud_controller/clock/scheduler'
55

66
BackgroundJobEnvironment.new(RakeConfig.config).setup_environment
77
scheduler = VCAP::CloudController::Scheduler.new(RakeConfig.config)

0 commit comments

Comments
 (0)