Skip to content

Commit

Permalink
Run RuboCop.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Apr 10, 2024
1 parent 71330b3 commit e2f74ce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
15 changes: 3 additions & 12 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 --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
Expand Down Expand Up @@ -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:
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions lib/grape/validations/params_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]) })
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/grape/validations/validators/values_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/grape/api_remount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e2f74ce

Please sign in to comment.