Skip to content

Commit

Permalink
Bump rubocop from 0.52.0 to 0.58.2
Browse files Browse the repository at this point in the history
[#157068838]
  • Loading branch information
Mike Kenyon committed Aug 17, 2018
1 parent 28b951d commit ea0bf33
Show file tree
Hide file tree
Showing 83 changed files with 230 additions and 204 deletions.
41 changes: 37 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ require:

AllCops:
TargetRubyVersion: 2.4
Include:
- '**/Gemfile'
- '**/Rakefile'
Exclude:
- vendor/**/*
- lib/diego/bbs/models/**/*
Expand Down Expand Up @@ -71,6 +68,14 @@ Lint/UnifiedInteger:
Exclude:
- db/migrations/**/*

Lint/UnneededCopDisableDirective:
Exclude:
- db/migrations/201[3-7]*

Lint/UnneededCopEnableDirective:
Exclude:
- db/migrations/20130806175100_support_30char_identifiers_for_oracle.rb

Lint/UnusedBlockArgument:
Enabled: false

Expand Down Expand Up @@ -146,6 +151,26 @@ Naming/HeredocDelimiterNaming:
Naming/PredicateName:
Enabled: false

Naming/UncommunicativeMethodParamName:
# Parameter names may be equal to or greater than this value
MinNameLength: 3
AllowNamesEndingInNumbers: true
# Whitelisted names that will not register an offense
AllowedNames:
- '_'
- e
- io
- id
- to
- by
- 'on'
- in
- at
- ip
- db
# Blacklisted names that will register an offense
ForbiddenNames: []

Naming/VariableNumber:
Enabled: false

Expand Down Expand Up @@ -180,6 +205,11 @@ Style/Encoding:
Exclude:
- '**/*.pb.rb'

Style/ExpandPathArguments:
Exclude:
- 'db/migrations/20130911111938_encrypt_app_env_json.rb'
- 'db/migrations/201805*'

Style/FormatString:
EnforcedStyle: sprintf

Expand Down Expand Up @@ -249,7 +279,10 @@ Style/TernaryParentheses:
Style/TrailingCommaInArguments:
Enabled: false

Style/TrailingCommaInLiteral:
Style/TrailingCommaInArrayLiteral:
Enabled: false

Style/TrailingCommaInHashLiteral:
Enabled: false

Style/TrailingUnderscoreVariable:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ group :test do
gem 'rspec-rails'
gem 'rspec-wait'
gem 'rspec_api_documentation'
gem 'rubocop', '~> 0.52.0'
gem 'rubocop', '~> 0.58.2'
gem 'timecop'
gem 'webmock', '> 2.3.1'
end
Expand Down
11 changes: 7 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
jaro_winkler (1.5.1-x86_64-darwin-17)
json (1.8.6)
json-schema (2.8.0)
addressable (>= 2.4)
Expand Down Expand Up @@ -365,17 +367,18 @@ GEM
json (~> 1.4, >= 1.4.6)
mustache (~> 0.99, >= 0.99.4)
rspec (>= 3.0.0)
rubocop (0.52.1)
rubocop (0.58.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.4.0.2, < 3.0)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-debug-ide (0.7.0.beta4)
rake (>= 0.8.1)
ruby-mysql (2.9.14)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
ruby_parser (3.8.3)
sexp_processor (~> 4.1)
Expand Down Expand Up @@ -509,7 +512,7 @@ DEPENDENCIES
rspec-rails
rspec-wait
rspec_api_documentation
rubocop (~> 0.52.0)
rubocop (~> 0.58.2)
ruby-debug-ide (>= 0.7.0.beta4)
rubyzip!
scientist
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if ENV['DB'] == 'postgresql'
ENV['DB'] = 'postgres'
end

require File.expand_path('../config/boot', __FILE__)
require File.expand_path('config/boot', __dir__)

require 'yaml'
require 'sequel'
Expand Down
2 changes: 1 addition & 1 deletion app/access/user_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def index?(object_class, params=nil)
return true if admin_user? || admin_read_only_user?
# allow related enumerations for certain models
related_model = params && params[:related_model]
related_model == Organization || related_model == Space
[Organization, Space].include? related_model
end

def read?(user)
Expand Down
2 changes: 1 addition & 1 deletion app/actions/package_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def copy(destination_app_guid:, source_package:, user_audit_info:, record_event:
record_audit_event(package, source_package, user_audit_info) if record_event
end

return package
package
rescue Sequel::ValidationFailed => e
raise InvalidPackage.new(e.message)
end
Expand Down
2 changes: 1 addition & 1 deletion app/actions/space_update_isolation_segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update(space, org, message)
space.db.transaction do
space.lock!

space.isolation_segment_guid = isolation_segment_guid ? isolation_segment_guid : nil
space.isolation_segment_guid = isolation_segment_guid || nil
space.save

Repositories::SpaceEventRepository.new.record_space_update(
Expand Down
2 changes: 1 addition & 1 deletion app/actions/task_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def submit_task(task)
end

def use_requested_name_or_generate_name(message)
message.requested?(:name) ? message.name : Random.new.bytes(4).unpack('H*').first
message.requested?(:name) ? message.name : Random.new.bytes(4).unpack1('H*')
end

def validate_maximum_disk!(message)
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/base/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ def inject_dependencies(dependencies={}); end
# so that they can be investigated and have more accurate error
# reporting added.
#
# @param [Symbol] op The method to dispatch to.
# @param [Symbol] operation The method to dispatch to.
#
# @param [Array] args The arguments to the method being dispatched to.
#
# @return [Object] Returns an array of [http response code, Header hash,
# body string], or just a body string.
def dispatch(op, *args)
logger.debug 'cc.dispatch', endpoint: op, args: args
check_authentication(op)
send(op, *args)
def dispatch(operation, *args)
logger.debug 'cc.dispatch', endpoint: operation, args: args
check_authentication(operation)
send(operation, *args)
rescue Sequel::ValidationFailed => e
raise self.class.translate_validation_exception(e, request_attrs)
rescue Sequel::HookFailed => e
Expand Down Expand Up @@ -131,10 +131,10 @@ def add_warning(warning)
set_header('X-Cf-Warnings', new_warning)
end

def check_authentication(op)
def check_authentication(operation)
# The logic here is a bit oddly ordered, but it supports the
# legacy calls setting a user, but not providing a token.
return if self.class.allow_unauthenticated_access?(op)
return if self.class.allow_unauthenticated_access?(operation)
return if VCAP::CloudController::SecurityContext.current_user

if VCAP::CloudController::SecurityContext.missing_token?
Expand Down Expand Up @@ -302,11 +302,11 @@ def authenticate_basic_auth(path)
end
end

def allow_unauthenticated_access?(op)
def allow_unauthenticated_access?(operation)
if @allow_unauthenticated_access_to_all_ops
@allow_unauthenticated_access_to_all_ops
elsif @allow_unauthenticated_access_ops
@allow_unauthenticated_access_ops.include?(op)
@allow_unauthenticated_access_ops.include?(operation)
end
end

Expand Down
28 changes: 14 additions & 14 deletions app/controllers/base/model_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def enumerate
)
end

def get_filtered_dataset_for_enumeration(model, ds, qp, opts)
Query.filtered_dataset_from_query_params(model, ds, qp, opts)
def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
Query.filtered_dataset_from_query_params(model, dataset, query_params, opts)
end

# Enumerate the related objects to the one with the given guid.
Expand All @@ -126,7 +126,7 @@ def enumerate_related(guid, name)

all_relationships = {}
[self.class.to_one_relationships, self.class.to_many_relationships].each do |rel|
all_relationships.merge!(rel) if rel && rel.any?
all_relationships.merge!(rel) if rel&.any?
end
associated_controller = VCAP::CloudController.controller_from_relationship(all_relationships[name])
associated_controller ||= VCAP::CloudController.controller_from_model_name(associated_model)
Expand Down Expand Up @@ -215,27 +215,27 @@ def do_related(verb, guid, name, other_guid, parent_model=model)
# Raises an exception if the user does not have rights to perform
# the operation on the object.
#
# @param [Symbol] op The type of operation to check for access
# @param [Symbol] operation The type of operation to check for access
#
# @param [Object] obj The object for which to validate access.
#
# @param [User] user The user for which to validate access.
#
# @param [Roles] The roles for the current user or client.
def validate_access(op, obj, *args)
if @access_context.cannot?("#{op}_with_token".to_sym, obj)
def validate_access(operation, obj, *args)
if @access_context.cannot?("#{operation}_with_token".to_sym, obj)
if obj.is_a? Class
obj = obj.to_s
end
logger.info('allowy.access-denied.insufficient-scope', op: "#{op}_with_token", obj: obj, user: user, roles: roles)
logger.info('allowy.access-denied.insufficient-scope', op: "#{operation}_with_token", obj: obj, user: user, roles: roles)
raise CloudController::Errors::ApiError.new_from_details('InsufficientScope')
end

if @access_context.cannot?(op, obj, *args)
if @access_context.cannot?(operation, obj, *args)
if obj.is_a? Class
obj = obj.to_s
end
logger.info('allowy.access-denied.not-authorized', op: op, obj: obj, user: user, roles: roles)
logger.info('allowy.access-denied.not-authorized', op: operation, obj: obj, user: user, roles: roles)
raise CloudController::Errors::ApiError.new_from_details('NotAuthorized')
end
end
Expand All @@ -247,11 +247,11 @@ def model
self.class.model
end

def redact_attributes(op, request_attributes)
def redact_attributes(operation, request_attributes)
request_attributes.dup.tap do |changes|
changes.each_key do |key|
attrib = self.class.attributes[key.to_sym]
changes[key] = Presenters::Censorship::PRIVATE_DATA_HIDDEN if attrib && attrib.redact_in?(op)
changes[key] = Presenters::Censorship::PRIVATE_DATA_HIDDEN if attrib && attrib.redact_in?(operation)
end
end
end
Expand Down Expand Up @@ -296,15 +296,15 @@ def raise_if_has_dependent_associations!(obj)
# Raises an exception if the object can't be found or if the current user
# doesn't have access to it.
#
# @param [Symbol] op The type of operation to check for access
# @param [Symbol] operation The type of operation to check for access
#
# @param [String] guid The GUID of the object to find.
#
# @return [Sequel::Model] The sequel model for the object, only if
# the use has access.
def find_guid_and_validate_access(op, guid, find_model=model)
def find_guid_and_validate_access(operation, guid, find_model=model)
obj = find_guid(guid, find_model)
validate_access(op, obj)
validate_access(operation, obj)
obj
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/app_bits_upload_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def inject_dependencies(dependencies)
model_class_name :ProcessModel
self.not_found_exception_name = 'AppNotFound'

def check_authentication(op)
def check_authentication(operation)
auth = env['HTTP_AUTHORIZATION']
grace_period = config.get(:app_bits_upload_grace_period_in_seconds)
relaxed_token_decoder = VCAP::CloudController::UaaTokenDecoder.new(config.get(:uaa), grace_period)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/runtime/app_usage_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def inject_dependencies(dependencies)

private

def get_filtered_dataset_for_enumeration(model, ds, qp, opts)
def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
after_guid = params['after_guid']
if after_guid
repository = Repositories::AppUsageEventRepository.new
previous_event = repository.find(after_guid)
raise CloudController::Errors::ApiError.new_from_details('BadQueryParameter', after_guid) unless previous_event
ds = ds.filter { id > previous_event.id }
dataset = dataset.filter { id > previous_event.id }
end
super(model, ds, qp, opts)
super(model, dataset, query_params, opts)
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/runtime/apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def permissions(guid)
end
end

def get_filtered_dataset_for_enumeration(model, ds, qp, opts)
AppQuery.filtered_dataset_from_query_params(model, ds, qp, opts)
def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
AppQuery.filtered_dataset_from_query_params(model, dataset, query_params, opts)
end

def filter_dataset(dataset)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/runtime/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def delete(guid)
do_delete(find_guid_and_validate_access(:delete, guid))
end

def get_filtered_dataset_for_enumeration(model, ds, qp, opts)
EventQuery.filtered_dataset_from_query_params(model, ds, qp, opts)
def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
EventQuery.filtered_dataset_from_query_params(model, dataset, query_params, opts)
end

define_messages
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/runtime/route_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def update(_guid)

private

def get_filtered_dataset_for_enumeration(model, ds, qp, opts)
RouteMappingQuery.filtered_dataset_from_query_params(model, ds, qp, opts)
def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
RouteMappingQuery.filtered_dataset_from_query_params(model, dataset, query_params, opts)
end

define_messages
Expand All @@ -86,8 +86,8 @@ def filter_dataset(dataset)
def get_app_port(process_guid, app_port)
if app_port.blank?
process = ProcessModel.find(guid: process_guid)
if !process.nil?
return process.ports[0] unless process.ports.blank?
if !process.nil? && !process.ports.blank?
return process.ports[0]
end
end

Expand Down
Loading

0 comments on commit ea0bf33

Please sign in to comment.