Skip to content

Commit

Permalink
Fix rubocop with most recent version 1.65.0 (#930)
Browse files Browse the repository at this point in the history
* configure Layout/MultilineMethodCallIndentation to ensure short indent
* update rubocop todo file
* Fix warning: use plurial fixture_paths for rails 7.1+
* Redo rubocop TODO and fix a couple of new offenses
  • Loading branch information
mathieujobin authored Jul 10, 2024
1 parent 5891061 commit 4be3741
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ AllCops:
NewCops: enable
TargetRubyVersion: 2.6

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/LineLength:
Max: 140
Exclude:
Expand Down
84 changes: 36 additions & 48 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# 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
# versions of RuboCop, may require this file to be generated again.

RubyVersionGlobalsUsage:
Exclude:
- apipie-rails.gemspec

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Severity, Include.
Expand All @@ -18,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 @@ -50,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 @@ -142,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 @@ -158,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 @@ -227,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 @@ -241,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 @@ -415,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 @@ -601,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 @@ -711,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 @@ -726,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 @@ -737,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 @@ -746,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 @@ -977,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 @@ -997,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 @@ -1020,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 @@ -1046,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 @@ -1092,7 +1088,7 @@ RSpec/MessageSpies:
RSpec/MultipleExpectations:
Max: 19

# Offense count: 163
# Offense count: 170
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 15
Expand All @@ -1117,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 @@ -1156,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.
RSpecRails/InferredSpecType:
Exclude:
- 'spec/controllers/pets_controller_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
Expand Down Expand Up @@ -1209,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 @@ -1420,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 @@ -1455,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 @@ -1465,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 @@ -1552,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 @@ -1687,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 @@ -1844,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 @@ -1944,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
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def call
end

parameters = Apipie::Generator::Swagger::MethodDescription::ParametersService
.new(@method_description, path: path, http_method: api.normalized_http_method)
.call
.new(@method_description, path: path, http_method: api.normalized_http_method)
.call

paths[path.swagger_path(@method_description)] ||= {}
paths[path.swagger_path(@method_description)][api.normalized_http_method] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def body_params_schema

if Apipie.configuration.generator.swagger.json_input_uses_refs?
composite = composite
.referenced("#{@method_description.operation_id}_input")
.referenced("#{@method_description.operation_id}_input")
end

swagger_schema_for_body = composite.to_swagger
Expand Down Expand Up @@ -80,7 +80,7 @@ def all_params
warn_path_parameter_not_described(name, @path)

result[name.to_sym] = Apipie::Generator::Swagger::ParamDescription
.create_for_missing_param(@method_description, name)
.create_for_missing_param(@method_description, name)
end

result
Expand All @@ -89,15 +89,15 @@ def all_params

def body_param_descriptions
@body_param_descriptions ||= all_params
.reject { |k, _| @path.param?(k) }
.values
.reject { |k, _| @path.param?(k) }
.values
end

def path_param_descriptions
@path_param_descriptions ||= all_params
.select { |k, _| @path.param?(k) }
.each_value { |desc| desc.required = true }
.values
.select { |k, _| @path.param?(k) }
.each_value { |desc| desc.required = true }
.values
end

# @return [Array]
Expand Down
Loading

0 comments on commit 4be3741

Please sign in to comment.