Skip to content

Commit

Permalink
rubocop fixes (#897)
Browse files Browse the repository at this point in the history
* rubocop fixes

* update todo file

* revert instance double
  • Loading branch information
mathieujobin authored Oct 11, 2023
1 parent c93dc6b commit 79edf74
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 39 deletions.
50 changes: 22 additions & 28 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 2023-06-09 05:29:05 UTC using RuboCop version 1.52.0.
# `rubocop --auto-gen-config --exclude-limit 200`
# on 2023-10-11 12:02:42 UTC using RuboCop version 1.57.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 Down Expand Up @@ -118,7 +118,7 @@ Layout/ElseAlignment:
- 'lib/apipie/param_description.rb'
- 'lib/apipie/resource_description.rb'

# Offense count: 58
# Offense count: 59
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
Expand All @@ -140,7 +140,7 @@ Layout/EmptyLineAfterGuardClause:

# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'app/controllers/apipie/apipies_controller.rb'
Expand Down Expand Up @@ -597,14 +597,13 @@ Layout/SpaceInsideParens:
- 'spec/lib/apipie/method_description/apis_service_spec.rb'
- 'spec/lib/swagger/swagger_dsl_spec.rb'

# Offense count: 15
# Offense count: 14
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Rakefile'
- 'lib/apipie/extractor/collector.rb'
- 'lib/apipie/method_description/apis_service.rb'
- 'lib/apipie/rspec/response_validation_helper.rb'
- 'spec/controllers/concerns_controller_spec.rb'
Expand Down Expand Up @@ -778,23 +777,17 @@ Lint/Void:
Exclude:
- 'spec/controllers/users_controller_spec.rb'

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

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 26

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

# Offense count: 24
# Offense count: 25
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 24
Expand All @@ -807,15 +800,15 @@ Metrics/MethodLength:
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 101
Max: 119

# Offense count: 4
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
MaxOptionalParameters: 5
Max: 6

# Offense count: 20
# Offense count: 21
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 25
Expand Down Expand Up @@ -961,7 +954,7 @@ RSpec/Be:
- 'spec/controllers/concerns_controller_spec.rb'
- 'spec/controllers/users_controller_spec.rb'

# Offense count: 59
# Offense count: 60
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
Expand Down Expand Up @@ -1054,7 +1047,7 @@ RSpec/EmptyLineAfterHook:
Exclude:
- 'spec/lib/apipie/apipies_controller_spec.rb'

# Offense count: 51
# Offense count: 52
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 85
Expand Down Expand Up @@ -1148,12 +1141,12 @@ RSpec/MessageSpies:
RSpec/MultipleExpectations:
Max: 19

# Offense count: 156
# Offense count: 160
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 15

# Offense count: 82
# Offense count: 85
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand All @@ -1173,7 +1166,7 @@ RSpec/NamedSubject:
- 'spec/lib/swagger/rake_swagger_spec.rb'
- 'spec/lib/swagger/swagger_dsl_spec.rb'

# Offense count: 94
# Offense count: 96
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6
Expand Down Expand Up @@ -1235,14 +1228,14 @@ RSpec/StubbedMock:
- 'spec/lib/apipie/extractor/writer_spec.rb'
- 'spec/lib/apipie/param_description_spec.rb'

# Offense count: 5
# Offense count: 6
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/lib/apipie/apipies_controller_spec.rb'
- 'spec/lib/apipie/extractor/recorder_spec.rb'
- 'spec/lib/apipie/extractor/writer_spec.rb'
- 'spec/lib/validators/array_validator_spec.rb'
- 'spec/lib/apipie/extractor/recorder_spec.rb'

# Offense count: 1
RSpec/VoidExpect:
Expand All @@ -1266,6 +1259,7 @@ Rails/Delegate:
- 'lib/apipie/response_description_adapter.rb'

# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Expand Down Expand Up @@ -1455,7 +1449,7 @@ Style/ClassCheck:
- 'lib/apipie/validator.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: ==, equal?, eql?
Style/ClassEqualityComparison:
Expand Down Expand Up @@ -1747,7 +1741,7 @@ Style/ParallelAssignment:
- 'lib/apipie/extractor.rb'
- 'lib/apipie/extractor/recorder.rb'

# Offense count: 6
# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Expand Down Expand Up @@ -1826,7 +1820,7 @@ Style/RedundantPercentQ:
Exclude:
- 'apipie-rails.gemspec'

# Offense count: 27
# Offense count: 29
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Expand Down Expand Up @@ -1927,7 +1921,7 @@ Style/StringConcatenation:
- 'lib/apipie/application.rb'
- 'lib/apipie/extractor/writer.rb'

# Offense count: 1212
# Offense count: 1214
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down
11 changes: 5 additions & 6 deletions lib/apipie/dsl_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,11 @@ def _apipie_define_validators(description)
end
end

if Apipie.configuration.process_value?
@api_params ||= {}
method_params.each do |_, param|
# params processing
@api_params[param.as] = param.process_value(params[:"#{param.name}"]) if params.key?(param.name)
end
return unless Apipie.configuration.process_value?
@api_params ||= {}
method_params.each do |_, param|
# params processing
@api_params[param.as] = param.process_value(params[:"#{param.name}"]) if params.key?(param.name)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def filter(version:, resource_id:, method_name: nil)

if method_name.present?
resources = resources.select do |resource_description|
resource_description._methods.select do |method_description_name, _|
resource_description._methods.any? do |method_description_name, _|
method_description_name == method_name
end.present?
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/apipie/response_description_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Validator
attr_reader :expected_type

def [](key)
return self.send(key) if self.respond_to?(key.to_s)
self.send(key) if self.respond_to?(key.to_s)
end

def initialize(expected_type, enum_values = nil, sub_properties = nil)
Expand Down Expand Up @@ -102,7 +102,7 @@ def initialize(name, expected_type, options = {}, sub_properties = [])
end

def [](key)
return self.send(key) if self.respond_to?(key.to_s)
self.send(key) if self.respond_to?(key.to_s)
end

def add_sub_property(prop_desc)
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'bundler/setup'

require 'simplecov'
SimpleCov.minimum_coverage 89
SimpleCov.minimum_coverage 91
SimpleCov.start

ENV["RAILS_ENV"] ||= 'test'
Expand Down

0 comments on commit 79edf74

Please sign in to comment.