Skip to content

Commit

Permalink
Merge branch 'master' into test_ruby_3_3
Browse files Browse the repository at this point in the history
  • Loading branch information
ericproulx authored Jan 3, 2024
2 parents f16688a + 91eec1a commit 2ea4676
Show file tree
Hide file tree
Showing 29 changed files with 147 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Style/MultilineIfModifier:
Style/RaiseArgs:
Enabled: false

Style/RedundantArrayConstructor:
Enabled: false # doesn't work well with params definition

Metrics/AbcSize:
Max: 45

Expand Down
79 changes: 71 additions & 8 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 2023-12-19 10:12:38 UTC using RuboCop version 1.50.2.
# on 2024-01-01 22:17:14 UTC using RuboCop version 1.59.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 All @@ -15,12 +15,13 @@ Gemspec/RequireMFA:
- 'grape.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/grape/dsl/routing_spec.rb'

# Offense count: 56
# Offense count: 55
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Expand Down Expand Up @@ -84,6 +85,7 @@ Lint/EmptyClass:
- 'spec/grape/middleware/stack_spec.rb'

# Offense count: 6
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/grape/api/instance.rb'
Expand All @@ -100,6 +102,7 @@ Metrics/MethodLength:
- 'lib/grape/endpoint.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Expand Down Expand Up @@ -215,7 +218,7 @@ RSpec/ExampleWording:
# This cop supports safe autocorrection (--autocorrect).
RSpec/ExpectActual:
Exclude:
- 'spec/routing/**/*'
- '**/spec/routing/**/*'
- 'spec/grape/endpoint/declared_spec.rb'
- 'spec/grape/middleware/exception_spec.rb'

Expand Down Expand Up @@ -278,13 +281,11 @@ RSpec/FilePath:
- 'spec/integration/rack/v2/headers_spec.rb'
- 'spec/integration/rack/v3/headers_spec.rb'

# Offense count: 12
# Configuration parameters: Max.
# Offense count: 6
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Exclude:
- 'spec/grape/exceptions/validation_errors_spec.rb'
- 'spec/grape/middleware/versioner/header_spec.rb'
- 'spec/grape/middleware/versioner/param_spec.rb'
- 'spec/grape/presenters/presenter_spec.rb'
- 'spec/shared/versioning_examples.rb'

Expand All @@ -300,7 +301,7 @@ RSpec/InstanceVariable:
- 'spec/grape/middleware/versioner/header_spec.rb'
- 'spec/grape/validations/validators/except_values_spec.rb'

# Offense count: 98
# Offense count: 97
RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/grape/api/defines_boolean_in_params_spec.rb'
Expand Down Expand Up @@ -556,6 +557,60 @@ RSpec/ScatteredSetup:
- 'spec/grape/util/inheritable_setting_spec.rb'
- 'spec/grape/validations_spec.rb'

# Offense count: 47
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/grape/api/custom_validations_spec.rb'
- 'spec/grape/api/deeply_included_options_spec.rb'
- 'spec/grape/api/defines_boolean_in_params_spec.rb'
- 'spec/grape/api/documentation_spec.rb'
- 'spec/grape/api/inherited_helpers_spec.rb'
- 'spec/grape/api/invalid_format_spec.rb'
- 'spec/grape/api/mount_and_helpers_order_spec.rb'
- 'spec/grape/api/mount_and_rescue_from_spec.rb'
- 'spec/grape/api/namespace_parameters_in_route_spec.rb'
- 'spec/grape/api/nested_helpers_spec.rb'
- 'spec/grape/api/optional_parameters_in_route_spec.rb'
- 'spec/grape/api/parameters_modification_spec.rb'
- 'spec/grape/api/patch_method_helpers_spec.rb'
- 'spec/grape/api/recognize_path_spec.rb'
- 'spec/grape/api/required_parameters_in_route_spec.rb'
- 'spec/grape/api/required_parameters_with_invalid_method_spec.rb'
- 'spec/grape/api/routes_with_requirements_spec.rb'
- 'spec/grape/api/shared_helpers_exactly_one_of_spec.rb'
- 'spec/grape/api/shared_helpers_spec.rb'
- 'spec/grape/dsl/inside_route_spec.rb'
- 'spec/grape/endpoint/declared_spec.rb'
- 'spec/grape/exceptions/body_parse_errors_spec.rb'
- 'spec/grape/extensions/param_builders/hash_spec.rb'
- 'spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb'
- 'spec/grape/extensions/param_builders/hashie/mash_spec.rb'
- 'spec/grape/integration/global_namespace_function_spec.rb'
- 'spec/grape/integration/rack_sendfile_spec.rb'
- 'spec/grape/loading_spec.rb'
- 'spec/grape/middleware/exception_spec.rb'
- 'spec/grape/validations/attributes_doc_spec.rb'
- 'spec/grape/validations/validators/all_or_none_spec.rb'
- 'spec/grape/validations/validators/allow_blank_spec.rb'
- 'spec/grape/validations/validators/at_least_one_of_spec.rb'
- 'spec/grape/validations/validators/coerce_spec.rb'
- 'spec/grape/validations/validators/default_spec.rb'
- 'spec/grape/validations/validators/exactly_one_of_spec.rb'
- 'spec/grape/validations/validators/except_values_spec.rb'
- 'spec/grape/validations/validators/mutual_exclusion_spec.rb'
- 'spec/grape/validations/validators/presence_spec.rb'
- 'spec/grape/validations/validators/regexp_spec.rb'
- 'spec/grape/validations/validators/same_as_spec.rb'
- 'spec/grape/validations/validators/values_spec.rb'
- 'spec/integration/eager_load/eager_load_spec.rb'
- 'spec/integration/multi_json/json_spec.rb'
- 'spec/integration/multi_xml/xml_spec.rb'
- 'spec/integration/rack/v2/headers_spec.rb'
- 'spec/integration/rack/v3/headers_spec.rb'

# Offense count: 9
RSpec/StubbedMock:
Exclude:
Expand Down Expand Up @@ -612,6 +667,14 @@ 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
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [#2393](https://github.com/ruby-grape/grape/pull/2393): Optimize AttributeTranslator - [@ericproulx](https://github.com/ericproulx).
* [#2395](https://github.com/ruby-grape/grape/pull/2395): Set `max-age` to 0 when `cookies.delete` - [@ericproulx](https://github.com/ericproulx).
* [#2397](https://github.com/ruby-grape/grape/pull/2397): Add support for ruby 3.3 - [@ericproulx](https://github.com/ericproulx).
* [#2399](https://github.com/ruby-grape/grape/pull/2399): Update `rubocop` to 1.59.0, `rubocop-performance` to 1.20.1 and `rubocop-rspec` to 2.25.0 - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

#### Fixes
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ class Color
end

def self.parse(value)
return new(value) if %w[blue red green]).include?(value)
return new(value) if %w[blue red green].include?(value)

Grape::Types::InvalidValue.new('Unsupported color')
end
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/multi_json.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/multi_xml.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rack_1_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rack_2_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rack_3_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rack_edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :development, :test do
gem 'bundler'
gem 'hashie'
gem 'rake'
gem 'rubocop', '1.50.2', require: false
gem 'rubocop-performance', '1.17.1', require: false
gem 'rubocop-rspec', '2.20.0', require: false
gem 'rubocop', '1.59.0', require: false
gem 'rubocop-performance', '1.20.1', require: false
gem 'rubocop-rspec', '2.25.0', require: false
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions lib/grape/exceptions/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def compose_message(key, **attributes)
end

def problem(key, **attributes)
translate_message("#{key}.problem".to_sym, **attributes)
translate_message(:"#{key}.problem", **attributes)
end

def summary(key, **attributes)
translate_message("#{key}.summary".to_sym, **attributes)
translate_message(:"#{key}.summary", **attributes)
end

def resolution(key, **attributes)
translate_message("#{key}.resolution".to_sym, **attributes)
translate_message(:"#{key}.resolution", **attributes)
end

def translate_attributes(keys, **options)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/exceptions/validation_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ValidationErrors < Grape::Exceptions::Base

def initialize(errors: [], headers: {}, **_options)
@errors = errors.group_by(&:params)
super message: full_messages.join(', '), status: 400, headers: headers
super(message: full_messages.join(', '), status: 400, headers: headers)
end

def each
Expand Down
5 changes: 2 additions & 3 deletions lib/grape/middleware/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ def insert_after(index, *args, &block)
end
ruby2_keywords :insert_after if respond_to?(:ruby2_keywords, true)

def use(*args, &block)
middleware = self.class::Middleware.new(*args, &block)
def use(...)
middleware = self.class::Middleware.new(...)
middlewares.push(middleware)
end
ruby2_keywords :use if respond_to?(:ruby2_keywords, true)

def merge_with(middleware_specs)
middleware_specs.each do |operation, *args|
Expand Down
4 changes: 2 additions & 2 deletions lib/grape/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def root_prefix

def uses_specific_format?
if settings.key?(:format) && settings.key?(:content_types)
(settings[:format] && Array(settings[:content_types]).size == 1)
settings[:format] && Array(settings[:content_types]).size == 1
else
false
end
end

def uses_path_versioning?
if settings.key?(:version) && settings[:version_options] && settings[:version_options].key?(:using)
(settings[:version] && settings[:version_options][:using] == :path)
settings[:version] && settings[:version_options][:using] == :path
else
false
end
Expand Down
Loading

0 comments on commit 2ea4676

Please sign in to comment.