Skip to content

Commit

Permalink
Enables and fixes all new cops.
Browse files Browse the repository at this point in the history
Fixes #1440
  • Loading branch information
iMacTia committed Aug 8, 2022
1 parent 5e01af3 commit 5bdee03
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 129 deletions.
204 changes: 98 additions & 106 deletions .rubocop.yml
Expand Up @@ -9,196 +9,188 @@ AllCops:
DisplayStyleGuide: true
TargetRubyVersion: 2.6

Metrics/BlockLength:
# Custom config
Gemspec/RequireMFA: # we don't know if this works with auto-deployments yet
Enabled: false
Layout/LineLength:
Exclude:
- spec/**/*.rb
- examples/**/*.rb

Metrics/ParameterLists:
Max: 6

Layout/EmptyLinesAroundAttributeAccessor: # (0.83)
Enabled: true

Layout/LineLength:
Metrics/BlockLength:
Exclude:
- spec/**/*.rb
- examples/**/*.rb

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/DeprecatedOpenSSLConstant: # (0.84)
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/DoubleNegation:
Enabled: false

Style/Documentation:
Exclude:
- 'spec/**/*'
- 'examples/**/*'
Style/DoubleNegation:
Enabled: false
Style/IfUnlessModifier:
Enabled: false

Style/ExponentialNotation:
# New cops
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
Enabled: true
Style/HashEachMethods:
Layout/LineContinuationLeadingSpace: # new in 1.31
Enabled: true
Style/HashTransformKeys:
Layout/LineContinuationSpacing: # new in 1.31
Enabled: true
Style/HashTransformValues:
Layout/LineEndStringConcatenationIndentation: # new in 1.18
Enabled: true
Style/IfUnlessModifier:
Enabled: false

Style/SlicingWithRange: # (0.83)
Layout/SpaceBeforeBrackets: # new in 1.7
Enabled: true

Layout/BeginEndAlignment: # (new in 0.91)
Lint/AmbiguousAssignment: # new in 1.7
Enabled: true
Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
Lint/AmbiguousOperatorPrecedence: # new in 1.21
Enabled: true
Lint/ConstantDefinitionInBlock: # (new in 0.91)
Lint/AmbiguousRange: # new in 1.19
Enabled: true
Lint/DuplicateElsifCondition: # (new in 0.88)
Lint/ConstantOverwrittenInRescue: # new in 1.31
Enabled: true
Lint/DuplicateRequire: # (new in 0.90)
Lint/DeprecatedConstants: # new in 1.8
Enabled: true
Lint/DuplicateRescueException: # (new in 0.89)
Lint/DuplicateBranch: # new in 1.3
Enabled: true
Lint/EmptyConditionalBody: # (new in 0.89)
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
Enabled: true
Lint/EmptyFile: # (new in 0.90)
Lint/EmptyBlock: # new in 1.1
Enabled: true
Lint/FloatComparison: # (new in 0.89)
Lint/EmptyClass: # new in 1.3
Enabled: true
Lint/HashCompareByIdentity: # (new in 0.93)
Lint/EmptyInPattern: # new in 1.16
Enabled: true
Lint/IdentityComparison: # (new in 0.91)
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
Enabled: true
Lint/MissingSuper: # (new in 0.89)
Lint/LambdaWithoutLiteralBlock: # new in 1.8
Enabled: true
Lint/MixedRegexpCaptureTypes: # (new in 0.85)
Lint/NoReturnInBeginEndBlocks: # new in 1.2
Enabled: true
Lint/OutOfRangeRegexpRef: # (new in 0.89)
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: true
Lint/RedundantSafeNavigation: # (new in 0.93)
Lint/NumberedParameterAssignment: # new in 1.9
Enabled: true
Lint/SelfAssignment: # (new in 0.89)
Lint/OrAssignmentToConstant: # new in 1.9
Enabled: true
Lint/TopLevelReturnWithArgument: # (new in 0.89)
Lint/RedundantDirGlobSort: # new in 1.8
Enabled: true
Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
Lint/RefinementImportMethods: # new in 1.27
Enabled: true
Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
Lint/RequireRangeParentheses: # new in 1.32
Enabled: true
Performance/CollectionLiteralInLoop: # (new in 1.8)
Lint/RequireRelativeSelfPath: # new in 1.22
Enabled: true
Performance/ConstantRegexp: # (new in 1.9)
Lint/SymbolConversion: # new in 1.9
Enabled: true
Performance/MethodObjectAsBlock: # (new in 1.9)
Lint/ToEnumArguments: # new in 1.1
Enabled: true
Performance/RedundantEqualityComparisonBlock: # (new in 1.10)
Lint/TripleQuotes: # new in 1.9
Enabled: true
Performance/RedundantSortBlock: # (new in 1.7)
Lint/UnexpectedBlockArity: # new in 1.5
Enabled: true
Performance/RedundantSplitRegexpArgument: # (new in 1.10)
Lint/UnmodifiedReduceAccumulator: # new in 1.1
Enabled: true
Performance/RedundantStringChars: # (new in 1.7)
Lint/UselessRuby2Keywords: # new in 1.23
Enabled: true
Performance/ReverseFirst: # (new in 1.7)
Naming/BlockForwarding: # new in 1.24
Enabled: true
Performance/SortReverse: # (new in 1.7)
Security/CompoundHash: # new in 1.28
Enabled: true
Performance/Squeeze: # (new in 1.7)
Security/IoMethods: # new in 1.22
Enabled: true
Performance/StringInclude: # (new in 1.7)
Style/ArgumentsForwarding: # new in 1.1
Enabled: true
Performance/Sum: # (new in 1.8)
Style/CollectionCompact: # new in 1.2
Enabled: true

Gemspec/DeprecatedAttributeAssignment:
Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true
Style/EmptyHeredoc: # new in 1.32
Enabled: true
Style/EndlessMethod: # new in 1.8
Enabled: true
Style/EnvHome: # new in 1.29
Enabled: true
Style/FetchEnvVar: # new in 1.28
Enabled: true
Style/FileRead: # new in 1.24
Enabled: true
Style/FileWrite: # new in 1.24
Enabled: true
Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
Style/HashConversion: # new in 1.10
Enabled: true
Layout/SpaceBeforeBrackets: # (new in 1.7)
Style/HashExcept: # new in 1.7
Enabled: true
Lint/AmbiguousAssignment: # (new in 1.7)
Style/IfWithBooleanLiteralBranches: # new in 1.9
Enabled: true
Lint/AmbiguousRange: # (new in 1.19)
Style/InPatternThen: # new in 1.16
Enabled: true
Lint/DeprecatedConstants: # (new in 1.8)
Style/MapCompactWithConditionalBlock: # new in 1.30
Enabled: true
Lint/DuplicateBranch: # (new in 1.3)
Style/MapToHash: # new in 1.24
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
Style/MultilineInPatternThen: # new in 1.16
Enabled: true
Lint/EmptyBlock: # (new in 1.1)
Style/NegatedIfElseCondition: # new in 1.2
Enabled: true
Lint/EmptyClass: # (new in 1.3)
Style/NestedFileDirname: # new in 1.26
Enabled: true
Lint/EmptyInPattern: # (new in 1.16)
Style/NilLambda: # new in 1.3
Enabled: true
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
Style/NumberedParameters: # new in 1.22
Enabled: true
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
Style/NumberedParametersLimit: # new in 1.22
Enabled: true
Lint/NumberedParameterAssignment: # (new in 1.9)
Style/ObjectThen: # new in 1.28
Enabled: true
Lint/OrAssignmentToConstant: # (new in 1.9)
Style/OpenStructUse: # new in 1.23
Enabled: true
Lint/RedundantDirGlobSort: # (new in 1.8)
Style/QuotedSymbols: # new in 1.16
Enabled: true
Lint/SymbolConversion: # (new in 1.9)
Style/RedundantArgument: # new in 1.4
Enabled: true
Lint/ToEnumArguments: # (new in 1.1)
Style/RedundantInitialize: # new in 1.27
Enabled: true
Lint/TripleQuotes: # (new in 1.9)
Style/RedundantSelfAssignmentBranch: # new in 1.19
Enabled: true
Lint/UnexpectedBlockArity: # (new in 1.5)
Style/SelectByRegexp: # new in 1.22
Enabled: true
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
Style/StringChars: # new in 1.12
Enabled: true
Naming/InclusiveLanguage: # (new in 1.18)
Style/SwapValues: # new in 1.1
Enabled: true
Style/ArgumentsForwarding: # (new in 1.1)
Performance/AncestorsInclude: # new in 1.7
Enabled: true
Style/CollectionCompact: # (new in 1.2)
Performance/BigDecimalWithNumericArgument: # new in 1.7
Enabled: true
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
Performance/BlockGivenWithExplicitBlock: # new in 1.9
Enabled: true
Style/EndlessMethod: # (new in 1.8)
Performance/CollectionLiteralInLoop: # new in 1.8
Enabled: true
Style/HashConversion: # (new in 1.10)
Performance/ConcurrentMonotonicTime: # new in 1.12
Enabled: true
Style/HashExcept: # (new in 1.7)
Performance/ConstantRegexp: # new in 1.9
Enabled: true
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
Performance/MapCompact: # new in 1.11
Enabled: true
Style/InPatternThen: # (new in 1.16)
Performance/MethodObjectAsBlock: # new in 1.9
Enabled: true
Style/MultilineInPatternThen: # (new in 1.16)
Performance/RedundantEqualityComparisonBlock: # new in 1.10
Enabled: true
Style/NegatedIfElseCondition: # (new in 1.2)
Performance/RedundantSortBlock: # new in 1.7
Enabled: true
Style/NilLambda: # (new in 1.3)
Performance/RedundantSplitRegexpArgument: # new in 1.10
Enabled: true
Style/QuotedSymbols: # (new in 1.16)
Performance/RedundantStringChars: # new in 1.7
Enabled: true
Style/RedundantArgument: # (new in 1.4)
Performance/ReverseFirst: # new in 1.7
Enabled: true
Style/RedundantSelfAssignmentBranch: # (new in 1.19)
Performance/SortReverse: # new in 1.7
Enabled: true
Style/StringChars: # (new in 1.12)
Performance/Squeeze: # new in 1.7
Enabled: true
Style/SwapValues: # (new in 1.1)
Performance/StringIdentifierArgument: # new in 1.13
Enabled: true
Performance/AncestorsInclude: # (new in 1.7)
Performance/StringInclude: # new in 1.7
Enabled: true
Performance/BigDecimalWithNumericArgument: # (new in 1.7)
Performance/Sum: # new in 1.8
Enabled: true
29 changes: 16 additions & 13 deletions .rubocop_todo.yml
@@ -1,17 +1,16 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-08-16 15:31:43 UTC using RuboCop version 1.19.0.
# on 2022-08-08 14:26:32 UTC using RuboCop version 1.33.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.

# Offense count: 7
# Offense count: 6
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/faraday/composite_read_io_spec.rb'
- 'spec/faraday/options/options_spec.rb'
- 'spec/faraday/rack_builder_spec.rb'
- 'spec/faraday/request/instrumentation_spec.rb'
Expand All @@ -24,28 +23,33 @@ Lint/EmptyBlock:
- 'spec/faraday/rack_builder_spec.rb'
- 'spec/faraday/response_spec.rb'

# Offense count: 16
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
# Offense count: 12
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 42

# Offense count: 3
# Offense count: 4
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 230

# Offense count: 12
# Configuration parameters: IgnoredMethods.
# Offense count: 9
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 13

# Offense count: 27
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# Offense count: 26
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
Max: 33

# Offense count: 8
# Configuration parameters: IgnoredMethods.
# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 6

# Offense count: 6
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 14

Expand All @@ -54,4 +58,3 @@ Style/DocumentDynamicEvalDefinition:
Exclude:
- 'lib/faraday/connection.rb'
- 'lib/faraday/options.rb'

2 changes: 1 addition & 1 deletion lib/faraday/adapter/test.rb
Expand Up @@ -272,7 +272,7 @@ def call(env)
stub, meta = stubs.match(env)

unless stub
raise Stubs::NotFound, "no stubbed request for #{env[:method]} "\
raise Stubs::NotFound, "no stubbed request for #{env[:method]} " \
"#{env[:url]} #{env[:body]}"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/connection.rb
Expand Up @@ -537,7 +537,7 @@ def proxy_from_env(url)
end

def find_default_proxy
uri = ENV['http_proxy']
uri = ENV.fetch('http_proxy', nil)
return unless uri && !uri.empty?

uri = "http://#{uri}" unless uri.match?(/^http/i)
Expand Down

0 comments on commit 5bdee03

Please sign in to comment.