Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable new RuboCops #3904

Merged
merged 2 commits into from
Jul 30, 2024
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
10 changes: 10 additions & 0 deletions .rubocop_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ RSpecRails/TravelAround:
Enabled: true
Style/SingleLineDoEndBlock:
Enabled: true
Gemspec/AddRuntimeDependency:
Enabled: true
Style/MapIntoArray:
Enabled: true
Style/SendWithLiteralMethodName:
Enabled: true
Style/SuperArguments:
Enabled: true
Rails/WhereRange:
Enabled: true

### Broken Cops that break code
Lint/ShadowedException: # Breaks "bundle exec rake rubocop" if enabled
Expand Down
26 changes: 24 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-07-24 13:31:59 UTC using RuboCop version 1.65.0.
# on 2024-07-25 15:02:19 UTC using RuboCop version 1.65.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -172,7 +172,7 @@ RSpec/BeforeAfterAll:
- 'spec/unit/lib/vcap/rest_api/event_query_spec.rb'
- 'spec/unit/lib/vcap/rest_api/query_spec.rb'

# Offense count: 6
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: NegatedMatcher.
RSpec/ChangeByZero:
Expand Down Expand Up @@ -634,6 +634,20 @@ Style/HashEachMethods:
Exclude:
- 'app/messages/validators/label_selector_requirement_validator.rb'

# Offense count: 9
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapIntoArray:
Exclude:
- 'app/actions/space_delete.rb'
- 'app/presenters/v3/relationship_presenter.rb'
- 'app/presenters/v3/to_many_relationship_presenter.rb'
- 'docs/v3/helpers/docs_helpers.rb'
- 'lib/cloud_controller/install_buildpacks.rb'
- 'lib/cloud_controller/metrics/periodic_updater.rb'
- 'spec/unit/controllers/v3/isolation_segments_controller_spec.rb'
- 'spec/unit/presenters/v3/relationship_presenter_spec.rb'
- 'spec/unit/presenters/v3/to_many_relationship_presenter_spec.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash:
Expand Down Expand Up @@ -714,6 +728,14 @@ Style/SelectByRegexp:
- 'app/controllers/v3/service_instances_controller.rb'
- 'app/controllers/v3/service_route_bindings_controller.rb'

# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowSend.
Style/SendWithLiteralMethodName:
Exclude:
- 'app/jobs/runtime/orphaned_blobs_cleanup.rb'
- 'app/jobs/v3/buildpack_cache_delete.rb'

# Offense count: 91
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/app_usage_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)

dataset = dataset.filter { id > previous_event.id }
end
super(model, dataset, query_params, opts)
super
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/runtime/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def before_update(org)
end
end

super(org)
super
end

def update(guid)
Expand Down Expand Up @@ -388,7 +388,7 @@ def after_create(organization)

def after_update(organization)
@organization_event_repository.record_organization_update(organization, UserAuditInfo.from_context(SecurityContext), request_attrs)
super(organization)
super
end

def get_current_role_guids(org)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/routes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
opts[:q].delete(opts[:q][orgs_index])
end

filtered_dataset = super(model, dataset, query_params, opts)
filtered_dataset = super
opts[:q] = orig_query

if org_guids.any?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/shared_domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def before_create
end

def after_create(domain)
super(domain)
super
return if domain.nil?
return if domain.router_group_guid.nil?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def before_update(quota)
end
end

super(quota)
super
end

def delete(guid)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/spaces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def before_update(space)
end
end

super(space)
super
end

def visible_relationship_dataset(name, obj)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/runtime/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def inject_dependencies(dependencies)

# related_guid should map back to other_id
def remove_related(related_guid, name, user_guid, find_model=model)
response = super(related_guid, name, user_guid, find_model)
response = super
user = User.first(guid: user_guid)
user.username = @uaa_username_lookup_client.usernames_for_ids([user.guid])[user.guid] || ''

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/services/service_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def get_filtered_dataset_for_enumeration(model, dataset_without_eager, query_par
end

def add_related(guid, name, other_guid, find_model=model)
return super(guid, name, other_guid, find_model) if name != :routes
return super if name != :routes

req_body = body.string.blank? ? '{}' : body

Expand Down Expand Up @@ -380,7 +380,7 @@ def bind_route(route_guid, instance_guid)
end

def remove_related(guid, name, other_guid, find_model=model)
return super(guid, name, other_guid, find_model) if name != :routes
return super if name != :routes

unbind_route(other_guid, guid)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/services/service_plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
left_join(:service_brokers, id: :services__service_broker_id).
where(service_brokers__guid: service_broker_guid)
else
super(model, dataset, query_params, opts)
super
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)

dataset = dataset.filter { id > previous_event.id }
end
super(model, dataset, query_params, opts)
super
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def get_filtered_dataset_for_enumeration(model, dataset, query_params, opts)
opts.delete(:q) if opts[:q].blank?

if org_filters.empty?
super(model, dataset, query_params, opts)
super
else
super(model, dataset, query_params, opts).where(space_id: select_on_org_filters_using_spaces(org_filters))
super.where(space_id: select_on_org_filters_using_spaces(org_filters))
end
ensure
opts[:q] = orig_query
Expand All @@ -155,13 +155,13 @@ def select_on_org_filters_using_spaces(org_filters)
define_routes

def add_related(guid, name, other_guid, find_model=model)
return super(guid, name, other_guid, find_model) if name != :routes
return super if name != :routes

bind_route(other_guid, guid)
end

def remove_related(guid, name, other_guid, find_model=model)
return super(guid, name, other_guid, find_model) if name != :routes
return super if name != :routes

unbind_route(other_guid, guid)
end
Expand Down
2 changes: 1 addition & 1 deletion app/fetchers/base_service_list_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def filter(message, dataset, klass)
dataset = dataset.where { Sequel[:service_brokers][:name] =~ message.service_broker_names }
end

super(message, dataset, klass)
super
end

def join_service_plans(_dataset)
Expand Down
2 changes: 1 addition & 1 deletion app/fetchers/service_offering_list_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def filter(message, dataset, klass)
)
end

super(message, dataset, klass)
super
end

def join_service_plans(dataset)
Expand Down
2 changes: 1 addition & 1 deletion app/fetchers/service_plan_list_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def filter(message, dataset, klass)
)
end

super(message, dataset, klass)
super
end

def join_service_plans(dataset)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/error_translator_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Jobs
class ErrorTranslatorJob < VCAP::CloudController::Jobs::WrappingJob
def error(job, err)
err = translate_error(err)
super(job, err)
super
end

def translate_error(err)
Expand Down
2 changes: 1 addition & 1 deletion app/messages/base_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(params)
@requested_keys = params.keys
disallowed_params = params.slice!(*allowed_keys)
@extra_keys = disallowed_params.keys
super(params)
super
end

def requested?(key)
Expand Down
2 changes: 1 addition & 1 deletion app/messages/list_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(params={})
params = params.symbolize_keys
@pagination_params = params.slice(*ALLOWED_PAGINATION_KEYS)
@pagination_options = PaginationOptions.from_params(params)
super(params)
super
end

def to_param_hash(exclude: [], fields: [])
Expand Down
2 changes: 1 addition & 1 deletion app/messages/manifest_process_update_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def self.readiness_health_check_endpoint_and_type_requested?
if: proc { |a| a.requested?(:timeout) }

def initialize(params={})
super(params)
super
@requested_keys << :health_check_timeout if requested? :timeout
@requested_keys << :health_check_endpoint if requested? :health_check_http_endpoint
@requested_keys << :readiness_health_check_endpoint if requested? :readiness_health_check_http_endpoint
Expand Down
2 changes: 1 addition & 1 deletion app/messages/process_update_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ProcessUpdateMessage < MetadataBaseMessage

# rubocop:disable Metrics/CyclomaticComplexity
def initialize(params={})
super(params)
super
params = params.deep_symbolize_keys
@requested_keys << :health_check_type if HashUtils.dig(params, :health_check)&.key?(:type)
@requested_keys << :health_check_timeout if HashUtils.dig(params, :health_check, :data)&.key?(:timeout)
Expand Down
2 changes: 1 addition & 1 deletion app/messages/route_destination_update_message.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module VCAP::CloudController
class RouteDestinationUpdateMessage < BaseMessage
def initialize(params)
super(params)
super
end

def self.key_requested?(key)
Expand Down
2 changes: 1 addition & 1 deletion app/models/runtime/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def remove_user(user)
can_remove = ([user.spaces, user.audited_spaces, user.managed_spaces].flatten & spaces).empty?
raise CloudController::Errors::ApiError.new_from_details('AssociationNotEmpty', 'user', 'spaces in the org') unless can_remove

super(user)
super
end

def remove_user_recursive(user)
Expand Down
2 changes: 1 addition & 1 deletion app/models/runtime/process_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def after_save

def to_hash(opts={})
opts[:redact] = (%w[environment_json system_env_json] unless VCAP::CloudController::Security::AccessContext.new.can?(:read_env, self))
super(opts)
super
end

def web?
Expand Down
4 changes: 2 additions & 2 deletions app/models/services/managed_service_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def as_summary_json
end

def to_hash(opts={})
return super(opts) if last_operation.nil?
return super if last_operation.nil?

last_operation_hash = last_operation.to_hash({})
super(opts).merge!('last_operation' => last_operation_hash)
super.merge!('last_operation' => last_operation_hash)
end

def gateway_data=(val)
Expand Down
2 changes: 1 addition & 1 deletion app/models/services/service_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def as_summary_json
def to_hash(opts={})
access_context = VCAP::CloudController::Security::AccessContext.new
opts[:redact] = ['credentials'] if access_context.cannot?(:read_env, self)
super(opts)
super
end

def credentials_with_serialization=(val)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/v2/service_key_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ServiceKeyPresenter < DefaultPresenter
present_for_class 'VCAP::CloudController::ServiceKey'

def entity_hash(controller, service_key, opts, depth, parents, orphans=nil)
default_hash = super(controller, service_key, opts, depth, parents, orphans)
default_hash = super
default_hash.merge!({
'service_key_parameters_url' => "/v2/service_keys/#{service_key.guid}/parameters",
'credentials' => redact_creds_if_necessary(service_key)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/v2/user_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class UserPresenter < DefaultPresenter
present_for_class 'VCAP::CloudController::User'

def entity_hash(controller, user, opts, depth, parents, orphans=nil)
super(controller, user, opts, depth, parents, orphans).merge(user_fields(user))
super.merge(user_fields(user))
end

def user_fields(user)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/v3/package_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(
censored_message: Censorship::REDACTED_CREDENTIAL
)

super(resource, show_secrets:, censored_message:)
super
end

def to_hash
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/v3/route_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(
censored_message: VCAP::CloudController::Presenters::Censorship::REDACTED_CREDENTIAL,
decorators: []
)
super(resource, show_secrets:, censored_message:, decorators:)
super
end

def to_hash
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Sequel::Model
# if e.errors.on(:some_attribute).include(:unique)

def default_validation_helpers_options(type)
val = super(type).deep_dup
val = super.deep_dup
val[:message] = type

val
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/paging/pagination_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PaginationOptions
attr_accessor :page, :per_page

def initialize(params)
super(params)
super

@page ||= PAGE_DEFAULT
@per_page ||= PER_PAGE_DEFAULT
Expand Down
2 changes: 1 addition & 1 deletion lib/sequel_plugins/vcap_normalization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module InstanceMethods
# Strips attributes of the model if requested.
def []=(key, value)
value = strip_if_needed(key, value)
super(key, value)
super
end

private
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fake_front_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class FakeFrontController < VCAP::CloudController::FrontController
use(FakeNginxReverseProxy)

def initialize(config)
super(config)
super
end
end
Loading