From e2f74ce38867c601190903d98c5626fa148d84fb Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 10 Apr 2024 03:28:18 -0400 Subject: [PATCH] Run RuboCop. --- .rubocop_todo.yml | 15 +++------------ lib/grape/validations/params_scope.rb | 4 ++-- .../validations/validators/values_validator.rb | 6 +++--- spec/grape/api_remount_spec.rb | 6 +++--- spec/grape/api_spec.rb | 4 ++-- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3a11f910ba..1b9ba67508 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 5000` -# on 2024-03-26 03:54:44 UTC using RuboCop version 1.59.0. +# `rubocop --auto-gen-config` +# on 2024-04-10 07:26:43 UTC using RuboCop version 1.62.1. # 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 @@ -270,15 +270,7 @@ Style/CombinableLoops: Style/FormatStringToken: EnforcedStyle: template -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedReceivers. -# AllowedReceivers: Thread.current -Style/HashEachMethods: - Exclude: - - 'lib/grape/middleware/stack.rb' - -# Offense count: 12 +# Offense count: 11 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: @@ -288,7 +280,6 @@ Style/OptionalBooleanParameter: - 'lib/grape/dsl/parameters.rb' - 'lib/grape/endpoint.rb' - 'lib/grape/serve_stream/sendfile_response.rb' - - 'lib/grape/validations/params_scope.rb' - 'lib/grape/validations/types/array_coercer.rb' - 'lib/grape/validations/types/custom_type_collection_coercer.rb' - 'lib/grape/validations/types/dry_type_coercer.rb' diff --git a/lib/grape/validations/params_scope.rb b/lib/grape/validations/params_scope.rb index 6eaf7abaa4..9948abd0d0 100644 --- a/lib/grape/validations/params_scope.rb +++ b/lib/grape/validations/params_scope.rb @@ -180,7 +180,7 @@ def push_declared_params(attrs, **opts) if lateral? @parent.push_declared_params(attrs, **opts) else - push_renamed_param(full_path + [attrs.first], opts[:as]) \ + push_renamed_param(full_path + [attrs.first], opts[:as]) if opts && opts[:as] @declared_params.concat(attrs.map { |attr| ::Grape::Validations::ParamsScope::Attr.new(attr, opts[:declared_params_scope]) }) @@ -467,7 +467,7 @@ def check_incompatible_option_values(default, values, except_values, excepts) end return unless excepts && !excepts.is_a?(Proc) - raise Grape::Exceptions::IncompatibleOptionValues.new(:default, default, :except, excepts) \ + raise Grape::Exceptions::IncompatibleOptionValues.new(:default, default, :except, excepts) unless Array(default).none? { |def_val| excepts.include?(def_val) } end diff --git a/lib/grape/validations/validators/values_validator.rb b/lib/grape/validations/validators/values_validator.rb index 8475ffb822..c248bd3e0f 100644 --- a/lib/grape/validations/validators/values_validator.rb +++ b/lib/grape/validations/validators/values_validator.rb @@ -36,13 +36,13 @@ def validate_param!(attr_name, params) param_array = val.nil? ? [nil] : Array.wrap(val) - raise validation_exception(attr_name, except_message) \ + raise validation_exception(attr_name, except_message) unless check_excepts(param_array) - raise validation_exception(attr_name, message(:values)) \ + raise validation_exception(attr_name, message(:values)) unless check_values(param_array, attr_name) - raise validation_exception(attr_name, message(:values)) \ + raise validation_exception(attr_name, message(:values)) if @proc && !validate_proc(@proc, param_array) end diff --git a/spec/grape/api_remount_spec.rb b/spec/grape/api_remount_spec.rb index 40b5505157..e4d13aad31 100644 --- a/spec/grape/api_remount_spec.rb +++ b/spec/grape/api_remount_spec.rb @@ -387,7 +387,7 @@ def app root_api.mount a_remounted_api, with: { path: 'scores', required_param: 'param_key' } end - it 'will use the dynamic configuration on all routes' do + it 'uses the dynamic configuration on all routes' do get 'api/votes', param_key: 'a' expect(last_response.body).to eql '10 votes' get 'api/scores', param_key: 'a' @@ -480,7 +480,7 @@ def printed_response end end - it 'will use the dynamic configuration on all routes' do + it 'uses the dynamic configuration on all routes' do root_api.mount(a_remounted_api, with: { some_value: 'response value' }) get '/location' @@ -497,7 +497,7 @@ def printed_response end end - it 'will use the dynamic configuration on all routes' do + it 'uses the dynamic configuration on all routes' do root_api.mount(a_remounted_api, with: { some_value: 'response value' }) get '/location' diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index f8bb785ff6..d2fc082bda 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -4333,12 +4333,12 @@ def uniqe_id_route it 'returns an error when the id is bad' do get '/v1/orders/abc' - expect(last_response.body).to be_eql('id is invalid') + expect(last_response.body).to eql('id is invalid') end it 'returns the given id when it is valid' do get '/v1/orders/1-2' - expect(last_response.body).to be_eql('1-2') + expect(last_response.body).to eql('1-2') end end