Skip to content

Commit

Permalink
Fix Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
iMacTia committed Dec 27, 2023
1 parent 38ad5e6 commit 835bf3f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
31 changes: 21 additions & 10 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`
# on 2022-08-08 14:26:32 UTC using RuboCop version 1.33.0.
# on 2023-12-27 11:12:52 UTC using RuboCop version 1.59.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 All @@ -23,23 +23,23 @@ Lint/EmptyBlock:
- 'spec/faraday/rack_builder_spec.rb'
- 'spec/faraday/response_spec.rb'

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

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

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

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

Expand All @@ -48,11 +48,22 @@ Metrics/MethodLength:
Metrics/ParameterLists:
Max: 6

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

# Offense count: 19
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames.
# RedundantRestArgumentNames: args, arguments
# RedundantKeywordRestArgumentNames: kwargs, options, opts
# RedundantBlockArgumentNames: blk, block, proc
Style/ArgumentsForwarding:
Exclude:
- 'lib/faraday.rb'
- 'lib/faraday/rack_builder.rb'

# Offense count: 3
Style/DocumentDynamicEvalDefinition:
Exclude:
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Faraday
class Connection
# A Set of allowed HTTP verbs.
METHODS = Set.new %i[get post put delete head patch options trace]
USER_AGENT = "Faraday v#{VERSION}"
USER_AGENT = "Faraday v#{VERSION}".freeze

# @return [Hash] URI query unencoded key/value pairs.
attr_reader :params
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/encoders/nested_params_encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def decode(query)

protected

SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/.freeze
SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/

def decode_pair(key, value, context)
subkeys = key.scan(SUBKEYS_REGEX)
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/options/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Faraday
:reason_phrase, :response_body) do
const_set(:ContentLength, 'Content-Length')
const_set(:StatusesWithoutBody, Set.new([204, 304]))
const_set(:SuccessfulStatuses, (200..299).freeze)
const_set(:SuccessfulStatuses, (200..299))

# A Set of HTTP verbs that typically send a body. If no body is set for
# these requests, the Content-Length header is set to 0.
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/request/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Request
# Doesn't try to encode bodies that already are in string form.
class Json < Middleware
MIME_TYPE = 'application/json'
MIME_TYPE_REGEX = %r{^application/(vnd\..+\+)?json$}.freeze
MIME_TYPE_REGEX = %r{^application/(vnd\..+\+)?json$}

def on_request(env)
match_content_type(env) do |data|
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Response
# client or server error responses.
class RaiseError < Middleware
# rubocop:disable Naming/ConstantName
ClientErrorStatuses = (400...500).freeze
ServerErrorStatuses = (500...600).freeze
ClientErrorStatuses = (400...500)
ServerErrorStatuses = (500...600)
# rubocop:enable Naming/ConstantName

def on_complete(env)
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class << self
attr_writer :default_space_encoding
end

ESCAPE_RE = /[^a-zA-Z0-9 .~_-]/.freeze
ESCAPE_RE = /[^a-zA-Z0-9 .~_-]/

def escape(str)
str.to_s.gsub(ESCAPE_RE) do |match|
Expand All @@ -37,7 +37,7 @@ def unescape(str)
CGI.unescape str.to_s
end

DEFAULT_SEP = /[&;] */n.freeze
DEFAULT_SEP = /[&;] */n

# Adapted from Rack
def parse_query(query)
Expand Down
11 changes: 6 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
minimum_coverage_by_file 26
end

# Ensure all /lib files are loaded
# so they will be included in the test coverage report.
Dir['./lib/**/*.rb'].sort.each { |file| require file }

require 'faraday'
require 'pry'

Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
# Ensure all /lib files are loaded
# so they will be included in the test coverage report.
Dir['./lib/**/*.rb'].each { |file| require file }

# Load all Rspec support files
Dir['./spec/support/**/*.rb'].each { |file| require file }

RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
Expand Down

0 comments on commit 835bf3f

Please sign in to comment.