Skip to content

Commit

Permalink
Bump Rubocop to 0.48.1
Browse files Browse the repository at this point in the history
- 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]
  • Loading branch information
Gerg committed May 27, 2017
1 parent 6355836 commit 2d5425a
Show file tree
Hide file tree
Showing 46 changed files with 183 additions and 186 deletions.
15 changes: 14 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ AllCops:
- vendor/**/*
- lib/diego/bbs/models/**/*

Lint/AmbiguousBlockAssociation:
Enabled: false

Lint/AmbiguousRegexpLiteral:
Enabled: false

# enable me for #85546748
Lint/HandleExceptions:
Enabled: false

Expand All @@ -39,6 +41,7 @@ Metrics/BlockLength:
- spec/**/*
- lib/cloud_controller/config.rb
- config/routes.rb
- lib/tasks/db.rake
Max: 50

Metrics/ClassLength:
Expand Down Expand Up @@ -98,6 +101,10 @@ Style/DoubleNegation:
Style/EachWithObject:
Enabled: false

Style/FileName:
Exclude:
- Guardfile

Style/FormatString:
EnforcedStyle: sprintf

Expand Down Expand Up @@ -155,6 +162,9 @@ Style/NumericLiterals:
Style/NumericPredicate:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/PredicateName:
Enabled: false

Expand Down Expand Up @@ -182,6 +192,9 @@ Style/SpaceAroundEqualsInParameterDefault:
Style/StructInheritance:
Enabled: false

Style/SymbolArray:
Enabled: false

Style/TernaryParentheses:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ GEM
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.47.1)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
Expand Down
10 changes: 5 additions & 5 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# cc Guardfile
# More info at https://github.com/guard/guard#readme

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

# These don't match the exact same dir structure between lib and spec
watch(%r{^lib/cloud_controller/legacy_api/(.+)\.rb$}) { |m| "spec/api/#{m[1]}_spec.rb" }
watch(%r{^lib/eventmachine/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/cloud_controller/legacy_api/(.+)\.rb$}) { |m| "spec/api/#{m[1]}_spec.rb" }
watch(%r{^lib/eventmachine/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
end
1 change: 0 additions & 1 deletion app/actions/route_mapping_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def add(message)
end

route_mapping

rescue Sequel::ValidationFailed => e
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)
raise DuplicateRouteMapping.new(DUPLICATE_MESSAGE)
Expand Down
1 change: 0 additions & 1 deletion app/actions/services/service_key_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def create(service_instance, key_attrs, arbitrary_parameters)
orphan_mitigator.attempt_delete_key(service_key)
raise e
end

rescue => e
errors << e
end
Expand Down
1 change: 0 additions & 1 deletion app/actions/services/service_key_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def delete_service_binding(service_binding)

service_instance.client.unbind(service_binding)
service_binding.destroy

rescue => e
errors << e
end
Expand Down
1 change: 0 additions & 1 deletion app/actions/v2/route_mapping_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def add
end

route_mapping

rescue Sequel::ValidationFailed => e
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)
raise DuplicateRouteMapping.new(DUPLICATE_MESSAGE)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/base/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def v2_api?
end

def unversioned_api?
!(env['PATH_INFO'] =~ %r{\A/v\d})
env['PATH_INFO'] !~ %r{\A/v\d}
end

def recursive_delete?
Expand Down
1 change: 0 additions & 1 deletion app/controllers/runtime/route_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def create
{ 'Location' => "#{self.class.path}/#{route_mapping.guid}" },
object_renderer.render_json(self.class, route_mapping, @opts)
]

rescue ::VCAP::CloudController::V2::RouteMappingCreate::DuplicateRouteMapping
raise CloudController::Errors::ApiError.new_from_details('RouteMappingTaken', route_mapping_taken_message(request_attrs))
rescue ::VCAP::CloudController::V2::RouteMappingCreate::UnavailableAppPort
Expand Down
1 change: 0 additions & 1 deletion app/controllers/services/service_bindings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def create
{ 'Location' => "#{self.class.path}/#{service_binding.guid}" },
object_renderer.render_json(self.class, service_binding, @opts)
]

rescue ServiceBindingCreate::ServiceInstanceNotBindable
raise CloudController::Errors::ApiError.new_from_details('UnbindableService')
rescue ServiceBindingCreate::VolumeMountServiceDisabled
Expand Down
1 change: 0 additions & 1 deletion app/controllers/v3/service_bindings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def destroy
ServiceBindingDelete.new(user_audit_info).single_delete_sync(binding)

head :no_content

rescue ServiceBindingDelete::FailedToDelete => e
unprocessable!(e.message)
end
Expand Down
1 change: 0 additions & 1 deletion app/jobs/v3/package_bits_copier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def perform
CloudController::DependencyLocator.instance.package_blobstore.cp_file_between_keys(@src_package_guid, @dest_package_guid)
checksums = { sha1: src_package.package_hash, sha256: src_package.sha256_checksum }
dest_package.succeed_upload!(checksums)

rescue => e
dest_package.fail_upload!("failed to copy - #{e.message}") if dest_package
raise
Expand Down
1 change: 0 additions & 1 deletion app/models/runtime/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def self.enabled?(feature_flag_name)
feature_flag = FeatureFlag.find(name: feature_flag_name.to_s)
return feature_flag.enabled if feature_flag
DEFAULT_FLAGS.fetch(feature_flag_name)

rescue KeyError
raise UndefinedFeatureFlagError.new "invalid key: #{feature_flag_name}"
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/message_bus/service_binding_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def to_hash
def self.censor_volume_mounts(volume_mounts)
return [] unless volume_mounts.is_a?(Array)
volume_mounts.map do |mount_info|
mount_info.reject { |k, _v| !WHITELISTED_VOLUME_FIELDS.include?(k) }
mount_info.select { |k, _v| WHITELISTED_VOLUME_FIELDS.include?(k) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/20141120182308_reprocess_diego_apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
def diego?(row)
decrypted = VCAP::CloudController::Encryptor.decrypt(row[:encrypted_environment_json], row[:salt])
environment_json = JSON.parse(decrypted)
!!(environment_json['DIEGO_RUN_BETA'] == 'true')
!environment_json['DIEGO_RUN_BETA'] != 'true'
end
end
1 change: 0 additions & 1 deletion lib/cloud_controller/blobstore/retryable_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def local_path
def with_retries(log_prefix, log_data)
retries ||= num_retries
yield

rescue *retryable_errors => e
retries -= 1

Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/blobstore/retryable_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def blob(key)
def with_retries(log_prefix, log_data)
retries ||= @num_retries
yield

rescue *@retryable_errors => e
retries -= 1

Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/diego/instances_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def crashed_instances_for_app(process)
}
end
crashed_instances

rescue => e
raise e if e.is_a? CloudController::Errors::InstancesUnavailable
logger.error('crashed_instances_for_app.error', error: e.to_s)
Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/diego/processes_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def sync
end

@workpool.drain

rescue CloudController::Errors::ApiError => e
if e.name == 'RunnerInvalidRequest'
logger.info('synced-invalid-desired-lrps', error: e.name, error_message: e.message)
Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/diego/stager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def initialize(config)

def stage(staging_details)
send_stage_package_request(staging_details)

rescue CloudController::Errors::ApiError => e
logger.error('stage.package', package_guid: staging_details.package.guid, staging_guid: staging_details.staging_guid, error: e)
build = BuildModel.find(guid: staging_details.staging_guid)
Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/diego/tps_instances_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def crashed_instances_for_app(process)
end

result

rescue CloudController::Errors::InstancesUnavailable => e
raise e
rescue => e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def fetch_and_process_records(paginated_dataset, controller, inline_relations_de
collection_transformer.transform(dataset_records, transform_opts) if collection_transformer

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

def default_visibility_filter
Expand Down
1 change: 0 additions & 1 deletion lib/cloud_controller/rule_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def self.validate_destination(destination)
end

return true

rescue NetAddr::ValidationError
return false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/security_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.missing_token?
end

def self.valid_token?
token && !(token == :invalid_token)
token && token != :invalid_token
end

def self.invalid_token?
Expand Down
3 changes: 1 addition & 2 deletions lib/tasks/buildpacks.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace :buildpacks do

desc "Install/Update buildpacks"
desc 'Install/Update buildpacks'
task :install do
buildpacks = RakeConfig.config[:install_buildpacks]
BackgroundJobEnvironment.new(RakeConfig.config).setup_environment do
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/clock.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace :clock do
desc "Start a recurring tasks"
desc 'Start a recurring tasks'
task :start do
require "cloud_controller/clock/scheduler"
require 'cloud_controller/clock/scheduler'

BackgroundJobEnvironment.new(RakeConfig.config).setup_environment
scheduler = VCAP::CloudController::Scheduler.new(RakeConfig.config)
Expand Down
Loading

0 comments on commit 2d5425a

Please sign in to comment.