From 6a0227cbca75085b12b69ac83919edc585a0c525 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 3 Jun 2023 09:01:46 +0900 Subject: [PATCH] Performance/InefficientHashSearch-20230602233137 (#884) * :police_car: regenerate rubocop todo * :police_car: Performance/InefficientHashSearch * :police_car: regenerate rubocop todo --------- Co-authored-by: Rubocop Challenger --- .rubocop_todo.yml | 109 ++++++++++-------------- lib/apipie/generator/swagger/warning.rb | 2 +- 2 files changed, 46 insertions(+), 65 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 72166460..2550fd5d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 180` -# on 2023-04-14 04:21:53 UTC using RuboCop version 1.44.1. +# on 2023-06-02 23:32:14 UTC using RuboCop version 1.52.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 @@ -14,10 +14,9 @@ Gemspec/DeprecatedAttributeAssignment: Exclude: - 'apipie-rails.gemspec' -# Offense count: 9 +# Offense count: 11 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec -# AllowedGems: bundler # Include: **/*.gemspec, **/Gemfile, **/gems.rb Gemspec/DevelopmentDependencies: Exclude: @@ -108,7 +107,7 @@ Layout/DotPosition: - 'spec/lib/apipie/generator/swagger/operation_id_spec.rb' - 'spec/lib/apipie/generator/swagger/param_description/type_spec.rb' -# Offense count: 7 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Layout/ElseAlignment: Exclude: @@ -119,7 +118,7 @@ Layout/ElseAlignment: - 'lib/apipie/param_description.rb' - 'lib/apipie/resource_description.rb' -# Offense count: 60 +# Offense count: 59 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: Exclude: @@ -155,7 +154,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: 57 +# Offense count: 56 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: @@ -193,7 +192,7 @@ Layout/EmptyLinesAroundAttributeAccessor: Exclude: - 'lib/apipie/configuration.rb' -# Offense count: 93 +# Offense count: 92 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines @@ -202,7 +201,6 @@ Layout/EmptyLinesAroundBlockBody: - 'app/controllers/apipie/apipies_controller.rb' - 'lib/tasks/apipie.rake' - 'spec/controllers/api/v1/architectures_controller_spec.rb' - - 'spec/controllers/api/v2/architectures_controller_spec.rb' - 'spec/controllers/concerns_controller_spec.rb' - 'spec/controllers/extended_controller_spec.rb' - 'spec/controllers/included_param_group_controller_spec.rb' @@ -288,7 +286,7 @@ Layout/EmptyLinesAroundModuleBody: - 'lib/apipie/tag_list_description.rb' - 'lib/apipie/validator.rb' -# Offense count: 7 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleAlignWith, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line @@ -374,9 +372,9 @@ Layout/IndentationConsistency: - 'lib/apipie/generator/swagger/param_description/name.rb' - 'spec/lib/apipie/param_group_spec.rb' -# Offense count: 10 +# Offense count: 14 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns. +# Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: Exclude: - 'app/controllers/apipie/apipies_controller.rb' @@ -440,13 +438,12 @@ Layout/MultilineMethodCallIndentation: - 'lib/apipie/generator/swagger/param_description/composite.rb' - 'lib/apipie/generator/swagger/param_description/type.rb' -# Offense count: 5 +# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Exclude: - - 'lib/apipie/application.rb' - 'lib/apipie/generator/swagger/param_description/composite.rb' - 'lib/apipie/param_description.rb' - 'lib/tasks/apipie.rake' @@ -622,18 +619,17 @@ Layout/TrailingEmptyLines: - 'spec/lib/apipie/generator/swagger/param_description_spec.rb' - 'spec/lib/apipie/param_group_spec.rb' -# Offense count: 16 +# Offense count: 15 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Exclude: - 'lib/apipie/error_description.rb' - - 'spec/dummy/app/controllers/api/v2/nested/resources_controller.rb' - 'spec/dummy/app/controllers/application_controller.rb' - 'spec/dummy/app/controllers/twitter_example_controller.rb' # Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Exclude: @@ -749,12 +745,11 @@ Lint/UnusedBlockArgument: - 'spec/lib/swagger/swagger_dsl_spec.rb' - 'spec/spec_helper.rb' -# Offense count: 26 +# Offense count: 24 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: - - 'lib/apipie/application.rb' - 'lib/apipie/dsl_definition.rb' - 'lib/apipie/response_description_adapter.rb' - 'lib/apipie/validator.rb' @@ -762,6 +757,7 @@ Lint/UnusedMethodArgument: - 'spec/support/custom_bool_validator.rb' # Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/UselessAssignment: Exclude: - 'lib/apipie/application.rb' @@ -776,13 +772,14 @@ Lint/UselessMethodDefinition: - 'spec/dummy/app/controllers/overridden_concerns_controller.rb' # Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: - 'spec/controllers/users_controller_spec.rb' # Offense count: 58 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 96 @@ -791,29 +788,24 @@ Metrics/AbcSize: Metrics/BlockNesting: Max: 4 -# Offense count: 25 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Offense count: 24 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 24 -# Offense count: 77 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Offense count: 78 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 58 -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ModuleLength: - Max: 119 - # Offense count: 4 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: MaxOptionalParameters: 5 Max: 6 -# Offense count: 21 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Offense count: 20 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 25 @@ -840,15 +832,16 @@ Naming/HeredocDelimiterCase: Exclude: - 'spec/dummy/app/controllers/users_controller.rb' -# Offense count: 6 +# Offense count: 7 # Configuration parameters: ForbiddenDelimiters. -# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'spec/dummy/app/controllers/twitter_example_controller.rb' - 'spec/dummy/app/controllers/users_controller.rb' # Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: @@ -880,7 +873,7 @@ Naming/PredicateName: # Offense count: 1 # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: - 'spec/dummy/app/controllers/users_controller.rb' @@ -906,12 +899,6 @@ Performance/Detect: Exclude: - 'spec/lib/swagger/rake_swagger_spec.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/InefficientHashSearch: - Exclude: - - 'lib/apipie/generator/swagger/warning.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Performance/RedundantBlockCall: @@ -940,11 +927,10 @@ Performance/StringIdentifierArgument: - 'lib/apipie/extractor/writer.rb' - 'spec/controllers/users_controller_spec.rb' -# Offense count: 6 +# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). Performance/StringReplacement: Exclude: - - 'app/controllers/apipie/apipies_controller.rb' - 'lib/apipie/application.rb' - 'lib/apipie/extractor/writer.rb' - 'lib/apipie/generator/swagger/operation_id.rb' @@ -984,7 +970,7 @@ RSpec/BeforeAfterAll: Exclude: - 'spec/controllers/users_controller_spec.rb' -# Offense count: 52 +# Offense count: 53 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -1012,14 +998,13 @@ RSpec/DescribeClass: - 'spec/lib/swagger/rake_swagger_spec.rb' - 'spec/lib/swagger/swagger_dsl_spec.rb' -# Offense count: 76 +# Offense count: 75 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: - 'spec/controllers/api/v1/architectures_controller_spec.rb' - - 'spec/controllers/api/v2/architectures_controller_spec.rb' - 'spec/controllers/api/v2/nested/resources_controller_spec.rb' - 'spec/controllers/included_param_group_controller_spec.rb' - 'spec/controllers/users_controller_spec.rb' @@ -1063,14 +1048,13 @@ RSpec/EmptyLineAfterHook: RSpec/ExampleLength: Max: 85 -# Offense count: 159 +# Offense count: 158 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works RSpec/ExampleWording: Exclude: - 'spec/controllers/api/v1/architectures_controller_spec.rb' - - 'spec/controllers/api/v2/architectures_controller_spec.rb' - 'spec/controllers/api/v2/nested/resources_controller_spec.rb' - 'spec/controllers/concerns_controller_spec.rb' - 'spec/controllers/extended_controller_spec.rb' @@ -1158,13 +1142,12 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 15 -# Offense count: 83 +# Offense count: 82 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/controllers/api/v1/architectures_controller_spec.rb' - - 'spec/controllers/api/v2/architectures_controller_spec.rb' - 'spec/controllers/api/v2/nested/resources_controller_spec.rb' - 'spec/controllers/users_controller_spec.rb' - 'spec/lib/apipie/generator/swagger/param_description/builder_spec.rb' @@ -1179,7 +1162,7 @@ RSpec/NamedSubject: - 'spec/lib/swagger/rake_swagger_spec.rb' - 'spec/lib/swagger/swagger_dsl_spec.rb' -# Offense count: 89 +# Offense count: 93 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 6 @@ -1297,13 +1280,12 @@ Rails/HttpStatus: - 'spec/dummy/app/controllers/pets_controller.rb' - 'spec/dummy/app/controllers/users_controller.rb' -# Offense count: 4 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/NegateInclude: Exclude: - 'lib/apipie/extractor/collector.rb' - 'lib/apipie/extractor/writer.rb' - - 'lib/apipie/generator/swagger/warning.rb' - 'spec/spec_helper.rb' # Offense count: 7 @@ -1322,7 +1304,7 @@ Rails/OutputSafety: - 'lib/apipie/helpers.rb' # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). Rails/Pluck: Exclude: - 'lib/apipie/extractor/writer.rb' @@ -1386,7 +1368,7 @@ Style/AndOr: # Offense count: 17 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch @@ -1463,7 +1445,7 @@ Style/ClassCheck: # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? Style/ClassEqualityComparison: Exclude: @@ -1497,13 +1479,12 @@ Style/CommentedKeyword: - 'lib/apipie/dsl_definition.rb' - 'lib/apipie/extractor/recorder.rb' -# Offense count: 9 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: - - 'app/controllers/apipie/apipies_controller.rb' - 'lib/apipie/extractor/writer.rb' - 'lib/apipie/param_description.rb' - 'lib/apipie/response_description.rb' @@ -1594,12 +1575,13 @@ Style/For: # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated +# AllowedMethods: redirect Style/FormatStringToken: EnforcedStyle: template -# Offense count: 33 +# Offense count: 31 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -1664,7 +1646,7 @@ Style/Lambda: # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Style/MethodCallWithoutArgsParentheses: Exclude: - 'lib/apipie/extractor/recorder.rb' @@ -1834,7 +1816,7 @@ Style/RedundantPercentQ: Exclude: - 'apipie-rails.gemspec' -# Offense count: 29 +# Offense count: 27 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -1895,12 +1877,11 @@ Style/Semicolon: Exclude: - 'lib/apipie/method_description.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfMethodIsEmpty. Style/SingleLineMethods: Exclude: - - 'lib/apipie/resource_description.rb' - 'lib/apipie/tag_list_description.rb' # Offense count: 6 @@ -1936,7 +1917,7 @@ Style/StringConcatenation: - 'lib/apipie/application.rb' - 'lib/apipie/extractor/writer.rb' -# Offense count: 1196 +# Offense count: 1210 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -2020,7 +2001,7 @@ Style/StringLiterals: - 'spec/support/rake.rb' - 'spec/test_engine/memes_controller_spec.rb' -# Offense count: 35 +# Offense count: 34 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinSize. # SupportedStyles: percent, brackets diff --git a/lib/apipie/generator/swagger/warning.rb b/lib/apipie/generator/swagger/warning.rb index 8e85f3cf..9ef9c7f1 100644 --- a/lib/apipie/generator/swagger/warning.rb +++ b/lib/apipie/generator/swagger/warning.rb @@ -59,7 +59,7 @@ def warn_through_writer # # @return [Apipie::Generator::Swagger::Warning] def self.for_code(code, method_id, message_attributes = {}) - if !CODES.values.include?(code) + if !CODES.value?(code) raise ArgumentError, 'Unknown warning code' end