Skip to content

Commit

Permalink
Merge branch 'master' into fix/validate_blank_error_message
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieujobin authored Jul 11, 2024
2 parents fe66db0 + 4be3741 commit cbd84b0
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require:
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
- rubocop-performance

inherit_from: .rubocop_todo.yml
Expand All @@ -12,6 +13,9 @@ AllCops:
NewCops: enable
TargetRubyVersion: 2.6

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/LineLength:
Max: 140
Exclude:
Expand Down
80 changes: 36 additions & 44 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 --exclude-limit 180`
# on 2024-02-19 23:31:58 UTC using RuboCop version 1.60.2.
# on 2024-07-10 23:53:15 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 All @@ -14,7 +14,7 @@ Gemspec/DeprecatedAttributeAssignment:
Exclude:
- 'apipie-rails.gemspec'

# Offense count: 11
# Offense count: 12
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
# SupportedStyles: Gemfile, gems.rb, gemspec
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
Expand Down Expand Up @@ -46,6 +46,13 @@ Gemspec/RequiredRubyVersion:
Exclude:
- 'spec/dummy/components/test_engine/test_engine.gemspec'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RubyVersionGlobalsUsage:
Exclude:
- 'apipie-rails.gemspec'

# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
Expand Down Expand Up @@ -138,7 +145,7 @@ Layout/EmptyLineAfterGuardClause:
- 'spec/lib/swagger/swagger_dsl_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 13
# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Expand All @@ -154,7 +161,7 @@ Layout/EmptyLineBetweenDefs:
- 'spec/dummy/app/controllers/pets_using_auto_views_controller.rb'
- 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb'

# Offense count: 55
# Offense count: 54
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLines:
Exclude:
Expand Down Expand Up @@ -223,7 +230,7 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/spec_helper.rb'
- 'spec/test_engine/memes_controller_spec.rb'

# Offense count: 44
# Offense count: 43
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Expand All @@ -237,7 +244,6 @@ Layout/EmptyLinesAroundClassBody:
- 'lib/apipie/markup.rb'
- 'lib/apipie/param_description.rb'
- 'lib/apipie/resource_description.rb'
- 'lib/apipie/response_description.rb'
- 'lib/apipie/response_description_adapter.rb'
- 'lib/apipie/see_description.rb'
- 'lib/apipie/tag_list_description.rb'
Expand Down Expand Up @@ -411,16 +417,6 @@ Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'lib/tasks/apipie.rake'

# Offense count: 14
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'lib/apipie/generator/swagger/param_description/builder.rb'
- 'lib/apipie/generator/swagger/param_description/composite.rb'
- 'lib/apipie/generator/swagger/param_description/type.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
Expand Down Expand Up @@ -597,12 +593,11 @@ Layout/TrailingEmptyLines:
- 'spec/lib/apipie/generator/swagger/param_description_spec.rb'
- 'spec/lib/apipie/param_group_spec.rb'

# Offense count: 15
# Offense count: 14
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'lib/apipie/error_description.rb'
- 'spec/dummy/app/controllers/application_controller.rb'
- 'spec/dummy/app/controllers/twitter_example_controller.rb'

Expand Down Expand Up @@ -707,7 +702,7 @@ Lint/UnderscorePrefixedVariableName:

# Offense count: 22
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'lib/apipie/configuration.rb'
Expand All @@ -722,7 +717,7 @@ Lint/UnusedBlockArgument:

# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/apipie/dsl_definition.rb'
Expand All @@ -733,6 +728,7 @@ Lint/UnusedMethodArgument:

# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'lib/apipie/application.rb'
Expand All @@ -742,24 +738,26 @@ Lint/UselessAssignment:

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
Lint/UselessMethodDefinition:
Exclude:
- 'spec/dummy/app/controllers/overridden_concerns_controller.rb'

# Offense count: 3
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CheckForMethodsWithNoSideEffects.
# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'spec/controllers/users_controller_spec.rb'
- 'spec/lib/swagger/swagger_dsl_spec.rb'

# Offense count: 60
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 96

# Offense count: 3
# Configuration parameters: CountBlocks.
# Offense count: 1
# Configuration parameters: CountBlocks, CountModifierForms.
Metrics/BlockNesting:
Max: 4

Expand Down Expand Up @@ -973,7 +971,7 @@ RSpec/DescribeClass:

# Offense count: 75
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
Expand All @@ -993,6 +991,7 @@ RSpec/DescribedClass:

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
RSpec/EmptyExampleGroup:
Exclude:
- 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb'
Expand All @@ -1016,7 +1015,7 @@ RSpec/EmptyLineAfterHook:
Exclude:
- 'spec/lib/apipie/apipies_controller_spec.rb'

# Offense count: 52
# Offense count: 55
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 85
Expand All @@ -1042,6 +1041,7 @@ RSpec/HookArgument:

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
RSpec/HooksBeforeExamples:
Exclude:
- 'spec/controllers/users_controller_spec.rb'
Expand Down Expand Up @@ -1088,7 +1088,7 @@ RSpec/MessageSpies:
RSpec/MultipleExpectations:
Max: 19

# Offense count: 163
# Offense count: 170
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 15
Expand All @@ -1113,7 +1113,7 @@ RSpec/NamedSubject:
- 'spec/lib/swagger/rake_swagger_spec.rb'
- 'spec/lib/swagger/swagger_dsl_spec.rb'

# Offense count: 97
# Offense count: 99
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6
Expand Down Expand Up @@ -1152,13 +1152,6 @@ RSpec/PredicateMatcher:
- 'spec/lib/apipie/file_handler_spec.rb'
- 'spec/lib/swagger/swagger_dsl_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences.
RSpec/Rails/InferredSpecType:
Exclude:
- 'spec/controllers/pets_controller_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
Expand Down Expand Up @@ -1205,7 +1198,7 @@ Rails/Delegate:
Exclude:
- 'lib/apipie/response_description_adapter.rb'

# Offense count: 24
# Offense count: 25
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Expand Down Expand Up @@ -1416,7 +1409,7 @@ Style/CommentedKeyword:
- 'lib/apipie/dsl_definition.rb'
- 'lib/apipie/extractor/recorder.rb'

# Offense count: 8
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Expand Down Expand Up @@ -1451,7 +1444,7 @@ Style/EmptyCaseCondition:

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowComments.
# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments.
# SupportedStyles: empty, nil, both
Style/EmptyElse:
Exclude:
Expand All @@ -1461,7 +1454,7 @@ Style/EmptyElse:

# Offense count: 27
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: compact, expanded
Style/EmptyMethod:
Exclude:
Expand Down Expand Up @@ -1548,7 +1541,7 @@ Style/HashExcept:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
# SupportedShorthandSyntax: always, never, either, consistent
# SupportedShorthandSyntax: always, never, either, consistent, either_consistent
Style/HashSyntax:
Exclude:
- 'spec/dummy/config/routes.rb'
Expand Down Expand Up @@ -1683,7 +1676,7 @@ Style/Proc:
- 'spec/lib/apipie/apipies_controller_spec.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Expand Down Expand Up @@ -1840,7 +1833,7 @@ Style/StringConcatenation:
- 'lib/apipie/application.rb'
- 'lib/apipie/extractor/writer.rb'

# Offense count: 1229
# Offense count: 1233
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down Expand Up @@ -1940,15 +1933,14 @@ Style/TrailingCommaInArrayLiteral:
- 'spec/controllers/users_controller_spec.rb'
- 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb'

# Offense count: 5
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/apipie/generator/swagger/param_description.rb'
- 'lib/apipie/generator/swagger/param_description/builder.rb'
- 'lib/apipie/response_description.rb'
- 'spec/controllers/users_controller_spec.rb'

# Offense count: 1
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
===========

## [v1.4.1](https://github.com/Apipie/apipie-rails/tree/v1.4.1) (2024-07-09)
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.4.0...v1.4.1)
* Fix multiple rubocop offenses via rubocop_challenger. (Mathieu Jobin)
* RSpec/ExampleWording (#913)
* Layout/FirstArrayElementIndentation (#914)
* Style/BlockDelimiters (#917)
* Style/MutableConstant (#916)
* Layout/InitialIndentation (#915)
* Performance/RegexpMatch (#918)
* Fix CI: build green for modern ruby, rack, and rubocop-rspec (#939) (Murray Steele)

## [v1.4.0](https://github.com/Apipie/apipie-rails/tree/v1.4.0) (2024-05-30)
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.3.0...v1.4.0)
* Add Ruby 3.3.0 to CI build matrix (#906) Masato Nakamura
Expand Down
1 change: 1 addition & 0 deletions apipie-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rubocop-rails'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'rubocop-performance'
s.add_development_dependency 'rubocop-rspec_rails' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7")
s.add_development_dependency "simplecov"
s.add_development_dependency "sqlite3"
end
12 changes: 6 additions & 6 deletions lib/apipie/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ def to_swagger_json(version, resource_id, method_name, language, clear_warnings

resources =
Apipie::Generator::Swagger::ResourceDescriptionsCollection
.new(resource_descriptions)
.filter(
resource_id: resource_id,
method_name: method_name,
version: version
)
.new(resource_descriptions)
.filter(
resource_id: resource_id,
method_name: method_name,
version: version
)

Apipie::SwaggerGenerator.generate_from_resources(
resources,
Expand Down
12 changes: 7 additions & 5 deletions lib/apipie/error_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class ErrorDescription

def self.from_dsl_data(args)
code_or_options, desc, options = args
Apipie::ErrorDescription.new(code_or_options,
desc,
options)
Apipie::ErrorDescription.new(code_or_options, desc, options)
end

def initialize(code_or_options, desc = nil, options = {})
Expand All @@ -17,9 +15,13 @@ def initialize(code_or_options, desc = nil, options = {})
@metadata = code_or_options[:meta]
@description = code_or_options[:desc] || code_or_options[:description]
else
@code =
@code =
if code_or_options.is_a? Symbol
Rack::Utils::SYMBOL_TO_STATUS_CODE[code_or_options]
begin
Rack::Utils.status_code(code_or_options)
rescue ArgumentError
nil
end
else
code_or_options
end
Expand Down
Loading

0 comments on commit cbd84b0

Please sign in to comment.