From 11defe7de329ef61f708a378398868278f233c94 Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 14 Jul 2023 21:25:05 +0200 Subject: [PATCH] Update rubbocop --- .rubocop.yml | 11 +- .rubocop/metrics.yml | 17 ++ .rubocop_todo.yml | 450 +++++++++++++++++++++++++++--- Gemfile | 4 +- lib/http/timeout/per_operation.rb | 2 +- 5 files changed, 434 insertions(+), 50 deletions(-) create mode 100644 .rubocop/metrics.yml diff --git a/.rubocop.yml b/.rubocop.yml index b531d30f..ee20b203 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,19 @@ inherit_from: - .rubocop_todo.yml - .rubocop/layout.yml + - .rubocop/metrics.yml - .rubocop/style.yml +require: + - rubocop-performance + - rubocop-rake + - rubocop-rspec + AllCops: + NewCops: enable DefaultFormatter: fuubar DisplayCopNames: true - NewCops: enable + DisplayStyleGuide: true + ExtraDetails: true + SuggestExtensions: true TargetRubyVersion: 2.6 diff --git a/.rubocop/metrics.yml b/.rubocop/metrics.yml new file mode 100644 index 00000000..f43a9f48 --- /dev/null +++ b/.rubocop/metrics.yml @@ -0,0 +1,17 @@ +Metrics/BlockLength: + Enabled: true + Exclude: + - "spec/**/*_spec.rb" + - "**/*.gemspec" + +Metrics/ClassLength: + Enabled: true + CountAsOne: [array, hash, heredoc, method_call] + +Metrics/MethodLength: + Enabled: true + CountAsOne: [array, hash, heredoc, method_call] + +Metrics/ModuleLength: + Enabled: true + CountAsOne: [array, hash, heredoc, method_call] diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 47d5f9fe..f0a468d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 100` -# on 2022-06-16 14:35:44 UTC using RuboCop version 1.30.1. +# on 2023-07-14 19:45:58 UTC using RuboCop version 1.54.2. # 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 @@ -8,13 +8,21 @@ # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. +# Configuration parameters: Severity, Include. # Include: **/*.gemspec Gemspec/DeprecatedAttributeAssignment: Exclude: - 'http.gemspec' -# Offense count: 53 +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'http.gemspec' + +# Offense count: 56 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: leading, trailing @@ -30,7 +38,7 @@ Layout/DotPosition: - 'spec/lib/http_spec.rb' - 'spec/support/http_handling_shared.rb' -# Offense count: 176 +# Offense count: 210 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -54,16 +62,18 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/support/http_handling_shared.rb' - 'spec/support/ssl_helper.rb' -# Offense count: 4 +# Offense count: 5 +# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/http/features/auto_deflate.rb' - 'lib/http/features/instrumentation.rb' - 'lib/http/features/logging.rb' - 'lib/http/features/normalize_uri.rb' + - 'spec/lib/http/features/instrumentation_spec.rb' -# Offense count: 8 -# Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max. +# Offense count: 9 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: Exclude: - 'lib/http/chainable.rb' @@ -74,34 +84,6 @@ Metrics/AbcSize: - 'lib/http/request.rb' - 'lib/http/response.rb' -# Offense count: 70 -# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine -Metrics/BlockLength: - Exclude: - - '**/*.gemspec' - - 'spec/lib/http/client_spec.rb' - - 'spec/lib/http/connection_spec.rb' - - 'spec/lib/http/content_type_spec.rb' - - 'spec/lib/http/features/auto_deflate_spec.rb' - - 'spec/lib/http/features/auto_inflate_spec.rb' - - 'spec/lib/http/features/instrumentation_spec.rb' - - 'spec/lib/http/features/logging_spec.rb' - - 'spec/lib/http/headers/mixin_spec.rb' - - 'spec/lib/http/headers_spec.rb' - - 'spec/lib/http/options/merge_spec.rb' - - 'spec/lib/http/redirector_spec.rb' - - 'spec/lib/http/request/body_spec.rb' - - 'spec/lib/http/request/writer_spec.rb' - - 'spec/lib/http/request_spec.rb' - - 'spec/lib/http/response/body_spec.rb' - - 'spec/lib/http/response/parser_spec.rb' - - 'spec/lib/http/response/status_spec.rb' - - 'spec/lib/http/response_spec.rb' - - 'spec/lib/http/uri_spec.rb' - - 'spec/lib/http_spec.rb' - - 'spec/support/http_handling_shared.rb' - # Offense count: 4 # Configuration parameters: CountComments, Max, CountAsOne. Metrics/ClassLength: @@ -111,26 +93,22 @@ Metrics/ClassLength: - 'lib/http/headers.rb' - 'lib/http/request.rb' -# Offense count: 2 -# Configuration parameters: IgnoredMethods, Max. +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: Exclude: - 'lib/http/chainable.rb' - 'lib/http/client.rb' -# Offense count: 18 -# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods. +# Offense count: 13 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: - - 'lib/http/chainable.rb' - 'lib/http/client.rb' - 'lib/http/connection.rb' - - 'lib/http/features/auto_deflate.rb' - - 'lib/http/features/auto_inflate.rb' - 'lib/http/headers.rb' - 'lib/http/options.rb' - 'lib/http/redirector.rb' - - 'lib/http/request.rb' - 'lib/http/response.rb' - 'lib/http/response/body.rb' - 'lib/http/timeout/global.rb' @@ -141,6 +119,362 @@ Metrics/ModuleLength: Exclude: - 'lib/http/chainable.rb' +# Offense count: 1 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'Rakefile' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Performance/RegexpMatch: + Exclude: + - 'lib/http/headers.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: OnlySumOrWithInitialValue. +Performance/Sum: + Exclude: + - 'lib/http/redirector.rb' + - 'spec/lib/http/request/body_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Performance/UnfreezeString: + Exclude: + - 'spec/lib/http/connection_spec.rb' + +# Offense count: 3 +RSpec/AnyInstance: + Exclude: + - 'spec/lib/http/client_spec.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: be, be_nil +RSpec/BeNil: + Exclude: + - 'spec/lib/http/options/body_spec.rb' + - 'spec/lib/http/options/form_spec.rb' + - 'spec/lib/http/options/json_spec.rb' + +# Offense count: 49 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/features/auto_inflate_spec.rb' + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response/parser_spec.rb' + - 'spec/lib/http_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - '**/spec/features/**/*' + - '**/spec/requests/**/*' + - '**/spec/routing/**/*' + - '**/spec/system/**/*' + - '**/spec/views/**/*' + - 'spec/regression_specs.rb' + +# Offense count: 8 +RSpec/DescribeMethod: + Exclude: + - 'spec/lib/http/options/body_spec.rb' + - 'spec/lib/http/options/features_spec.rb' + - 'spec/lib/http/options/form_spec.rb' + - 'spec/lib/http/options/headers_spec.rb' + - 'spec/lib/http/options/json_spec.rb' + - 'spec/lib/http/options/merge_spec.rb' + - 'spec/lib/http/options/new_spec.rb' + - 'spec/lib/http/options/proxy_spec.rb' + +# Offense count: 119 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SkipBlocks, EnforcedStyle. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/features/auto_deflate_spec.rb' + - 'spec/lib/http/features/auto_inflate_spec.rb' + - 'spec/lib/http/features/instrumentation_spec.rb' + - 'spec/lib/http/options/body_spec.rb' + - 'spec/lib/http/options/features_spec.rb' + - 'spec/lib/http/options/form_spec.rb' + - 'spec/lib/http/options/headers_spec.rb' + - 'spec/lib/http/options/json_spec.rb' + - 'spec/lib/http/options/merge_spec.rb' + - 'spec/lib/http/options/new_spec.rb' + - 'spec/lib/http/options/proxy_spec.rb' + - 'spec/lib/http/request/body_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterExampleGroup: + Exclude: + - 'spec/lib/http/response_spec.rb' + +# Offense count: 22 +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterFinalLet: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/lib/http/request/body_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response/status_spec.rb' + - 'spec/lib/http/response_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. +RSpec/EmptyLineAfterHook: + Exclude: + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/request_spec.rb' + +# Offense count: 15 +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterSubject: + Exclude: + - 'spec/lib/http/content_type_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response/parser_spec.rb' + - 'spec/lib/http/response/status_spec.rb' + - 'spec/lib/http/response_spec.rb' + - 'spec/lib/http/uri_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 54 +# Configuration parameters: Max, CountAsOne. +RSpec/ExampleLength: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/features/auto_deflate_spec.rb' + - 'spec/lib/http/features/logging_spec.rb' + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/options/features_spec.rb' + - 'spec/lib/http/options/headers_spec.rb' + - 'spec/lib/http/options/merge_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/lib/http/request/body_spec.rb' + - 'spec/lib/http/request/writer_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/uri_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 22 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/lib/http/features/instrumentation_spec.rb' + - 'spec/lib/http/features/logging_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 12 +RSpec/ExpectInHook: + Exclude: + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/request/writer_spec.rb' + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/regression_specs.rb' + +# Offense count: 6 +# Configuration parameters: Max. +RSpec/IndexedLet: + Exclude: + - 'spec/lib/http/request/body_spec.rb' + +# Offense count: 2 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/lib/http/redirector_spec.rb' + +# Offense count: 17 +# This cop supports safe autocorrection (--autocorrect). +RSpec/LeadingSubject: + Exclude: + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/request/body_spec.rb' + - 'spec/lib/http/request/writer_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response_spec.rb' + - 'spec/lib/http/uri_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/MatchArray: + Exclude: + - 'spec/lib/http/headers_spec.rb' + +# Offense count: 37 +# Configuration parameters: . +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + EnforcedStyle: receive + +# Offense count: 59 +# Configuration parameters: Max. +RSpec/MultipleExpectations: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/features/auto_deflate_spec.rb' + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/options/body_spec.rb' + - 'spec/lib/http/options/features_spec.rb' + - 'spec/lib/http/options/form_spec.rb' + - 'spec/lib/http/options/headers_spec.rb' + - 'spec/lib/http/options/json_spec.rb' + - 'spec/lib/http/options/merge_spec.rb' + - 'spec/lib/http/options/proxy_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response/parser_spec.rb' + - 'spec/lib/http/uri_spec.rb' + - 'spec/lib/http_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 3 +# Configuration parameters: AllowSubject, Max. +RSpec/MultipleMemoizedHelpers: + Exclude: + - 'spec/lib/http/response_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +RSpec/MultipleSubjects: + Exclude: + - 'spec/lib/http/uri_spec.rb' + +# Offense count: 58 +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: + Exclude: + - 'spec/lib/http/features/auto_deflate_spec.rb' + - 'spec/lib/http/options_spec.rb' + - 'spec/lib/http/request/body_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response/parser_spec.rb' + - 'spec/lib/http/response/status_spec.rb' + - 'spec/lib/http/response_spec.rb' + +# Offense count: 15 +# Configuration parameters: Max, AllowedGroups. +RSpec/NestedGroups: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/redirector_spec.rb' + - 'spec/lib/http/request_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 2 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/lib/http/request/writer_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 15 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: not_to, to_not +RSpec/NotToNot: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response/status_spec.rb' + - 'spec/support/http_handling_shared.rb' + +# Offense count: 4 +RSpec/PendingWithoutReason: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 2 +RSpec/RepeatedDescription: + Exclude: + - 'spec/lib/http_spec.rb' + +# Offense count: 12 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: and_return, block +RSpec/ReturnFromStub: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/connection_spec.rb' + +# Offense count: 12 +RSpec/StubbedMock: + Exclude: + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/request/writer_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowedPatterns. +# SupportedStyles: snake_case, camelCase +RSpec/VariableName: + Exclude: + - 'spec/lib/http/headers_spec.rb' + +# Offense count: 11 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/lib/http/connection_spec.rb' + - 'spec/lib/http/headers_spec.rb' + - 'spec/lib/http/response/body_spec.rb' + - 'spec/lib/http/response/status_spec.rb' + - 'spec/lib/http/response_spec.rb' + - 'spec/lib/http_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rake/Desc: + Exclude: + - 'Rakefile' + # Offense count: 1 Security/CompoundHash: Exclude: @@ -196,11 +530,35 @@ Style/OptionalBooleanParameter: - 'lib/http/timeout/per_operation.rb' - 'lib/http/uri.rb' -# Offense count: 3 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. +Style/RedundantConstantBase: + Exclude: + - 'spec/lib/http/headers_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantCurrentDirectoryInPath: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpArgument: + Exclude: + - 'spec/lib/http/client_spec.rb' + - 'spec/lib/http/connection_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Exclude: + - 'lib/http/features/auto_deflate.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Exclude: - - 'lib/http/chainable.rb' - 'spec/lib/http/options/proxy_spec.rb' diff --git a/Gemfile b/Gemfile index 0d4e7fe8..917278f7 100644 --- a/Gemfile +++ b/Gemfile @@ -27,10 +27,10 @@ group :test do gem "backports" - gem "rubocop", "~> 1.30.0" + gem "rubocop", "~> 1.54.2" gem "rubocop-performance" gem "rubocop-rake" - gem "rubocop-rspec" + gem "rubocop-rspec", "~> 2.22.0" gem "simplecov", :require => false gem "simplecov-lcov", :require => false diff --git a/lib/http/timeout/per_operation.rb b/lib/http/timeout/per_operation.rb index 76015a75..f5fbf093 100644 --- a/lib/http/timeout/per_operation.rb +++ b/lib/http/timeout/per_operation.rb @@ -14,7 +14,7 @@ class PerOperation < Null KEYS = %i[read write connect].to_h { |k| [k, :"#{k}_timeout"] }.freeze class << self - def normalize_options(options) + def normalize_options(options) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity normalized = {} original = options.dup