Compare commits

...

6 Commits

Author SHA1 Message Date
Mattia Giuffrida
074506e67c Use latest Ruby version to publish and run rubocop 2023-12-28 18:09:17 +01:00
Mattia Giuffrida
898f203584 Run rubocop in CI using Ruby 3.3 2023-12-28 18:09:17 +01:00
Mattia Giuffrida
f0f549d7ef Fix Rubocop offenses 2023-12-28 18:09:17 +01:00
Mattia Giuffrida
caa4ff42f8 Update GitHub workflows, add 3.3 to CI matrix 2023-12-28 18:09:17 +01:00
Mattia Giuffrida
13732f7ff2 Remove ruby2_keywords dependency 2023-12-28 18:09:17 +01:00
Mattia Giuffrida
8cbfd758c2 Make 3.0 the minimum supported Ruby version 2023-12-28 18:09:17 +01:00
14 changed files with 43 additions and 34 deletions

View File

@ -24,10 +24,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Ruby 2.7 - name: Setup Ruby 3.x
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.7 ruby-version: 3
bundler-cache: true bundler-cache: true
- name: Rubocop - name: Rubocop
@ -43,7 +43,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ] ruby: [ '3.0', '3.1', '3.2', '3.3' ]
experimental: [false] experimental: [false]
include: include:
- ruby: head - ruby: head
@ -63,7 +63,6 @@ jobs:
run: bundle exec rake run: bundle exec rake
- name: Test External Adapters - name: Test External Adapters
if: ${{ matrix.ruby != '2.6' }}
continue-on-error: ${{ matrix.experimental }} continue-on-error: ${{ matrix.experimental }}
run: bundle exec bake test:external run: bundle exec bake test:external

View File

@ -14,10 +14,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Ruby 2.7 - name: Setup Ruby 3.x
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.7 ruby-version: 3
- name: Publish to RubyGems - name: Publish to RubyGems
uses: dawidd6/action-publish-gem@v1 uses: dawidd6/action-publish-gem@v1

View File

@ -7,7 +7,7 @@ require:
AllCops: AllCops:
DisplayCopNames: true DisplayCopNames: true
DisplayStyleGuide: true DisplayStyleGuide: true
TargetRubyVersion: 2.6 TargetRubyVersion: 3.0
# Custom config # Custom config
Gemspec/RequireMFA: # we don't know if this works with auto-deployments yet Gemspec/RequireMFA: # we don't know if this works with auto-deployments yet

View File

@ -1,6 +1,6 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config` # `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 # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
@ -23,23 +23,23 @@ Lint/EmptyBlock:
- 'spec/faraday/rack_builder_spec.rb' - 'spec/faraday/rack_builder_spec.rb'
- 'spec/faraday/response_spec.rb' - 'spec/faraday/response_spec.rb'
# Offense count: 12 # Offense count: 13
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize: Metrics/AbcSize:
Max: 42 Max: 42
# Offense count: 4 # Offense count: 3
# Configuration parameters: CountComments, CountAsOne. # Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength: Metrics/ClassLength:
Max: 230 Max: 225
# Offense count: 9 # Offense count: 9
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. # Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 13 Max: 13
# Offense count: 26 # Offense count: 27
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength: Metrics/MethodLength:
Max: 33 Max: 33
@ -48,11 +48,22 @@ Metrics/MethodLength:
Metrics/ParameterLists: Metrics/ParameterLists:
Max: 6 Max: 6
# Offense count: 6 # Offense count: 7
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. # Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 14 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 # Offense count: 3
Style/DocumentDynamicEvalDefinition: Style/DocumentDynamicEvalDefinition:
Exclude: Exclude:

View File

@ -35,7 +35,7 @@ Need more details? See the [Faraday API Documentation][apidoc] to see how it wor
This library aims to support and is [tested against][actions] the currently officially supported Ruby This library aims to support and is [tested against][actions] the currently officially supported Ruby
implementations. This means that, even without a major release, we could add or drop support for Ruby versions, implementations. This means that, even without a major release, we could add or drop support for Ruby versions,
following their [EOL](https://endoflife.date/ruby). following their [EOL](https://endoflife.date/ruby).
Currently that means we support Ruby 2.6+ Currently that means we support Ruby 3.0+
If something doesn't work on one of these Ruby versions, it's a bug. If something doesn't work on one of these Ruby versions, it's a bug.

View File

@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://lostisland.github.io/faraday' spec.homepage = 'https://lostisland.github.io/faraday'
spec.licenses = ['MIT'] spec.licenses = ['MIT']
spec.required_ruby_version = '>= 2.6' spec.required_ruby_version = '>= 3.0'
# faraday-net_http is the "default adapter", but being a Faraday dependency it can't # faraday-net_http is the "default adapter", but being a Faraday dependency it can't
# control which version of faraday it will be pulled from. # control which version of faraday it will be pulled from.
@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
# This way, we can release minor versions of the adapter with "breaking" changes for older versions of Faraday # This way, we can release minor versions of the adapter with "breaking" changes for older versions of Faraday
# and then bump the version requirement on the next compatible version of faraday. # and then bump the version requirement on the next compatible version of faraday.
spec.add_dependency 'faraday-net_http', '>= 2.0', '< 3.1' spec.add_dependency 'faraday-net_http', '>= 2.0', '< 3.1'
spec.add_dependency 'ruby2_keywords', '>= 0.0.4'
# Includes `examples` and `spec` to allow external adapter gems to run Faraday unit and integration tests # Includes `examples` and `spec` to allow external adapter gems to run Faraday unit and integration tests
spec.files = Dir['CHANGELOG.md', '{examples,lib,spec}/**/*', 'LICENSE.md', 'Rakefile', 'README.md'] spec.files = Dir['CHANGELOG.md', '{examples,lib,spec}/**/*', 'LICENSE.md', 'Rakefile', 'README.md']

View File

@ -15,7 +15,7 @@ module Faraday
class Connection class Connection
# A Set of allowed HTTP verbs. # A Set of allowed HTTP verbs.
METHODS = Set.new %i[get post put delete head patch options trace] 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. # @return [Hash] URI query unencoded key/value pairs.
attr_reader :params attr_reader :params

View File

@ -102,7 +102,7 @@ module Faraday
protected protected
SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/.freeze SUBKEYS_REGEX = /[^\[\]]+(?:\]?\[\])?/
def decode_pair(key, value, context) def decode_pair(key, value, context)
subkeys = key.scan(SUBKEYS_REGEX) subkeys = key.scan(SUBKEYS_REGEX)

View File

@ -60,7 +60,7 @@ module Faraday
:reason_phrase, :response_body) do :reason_phrase, :response_body) do
const_set(:ContentLength, 'Content-Length') const_set(:ContentLength, 'Content-Length')
const_set(:StatusesWithoutBody, Set.new([204, 304])) 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 # 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. # these requests, the Content-Length header is set to 0.

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'ruby2_keywords'
require 'faraday/adapter_registry' require 'faraday/adapter_registry'
module Faraday module Faraday

View File

@ -13,7 +13,7 @@ module Faraday
# Doesn't try to encode bodies that already are in string form. # Doesn't try to encode bodies that already are in string form.
class Json < Middleware class Json < Middleware
MIME_TYPE = 'application/json' MIME_TYPE = 'application/json'
MIME_TYPE_REGEX = %r{^application/(vnd\..+\+)?json$}.freeze MIME_TYPE_REGEX = %r{^application/(vnd\..+\+)?json$}
def on_request(env) def on_request(env)
match_content_type(env) do |data| match_content_type(env) do |data|

View File

@ -6,8 +6,8 @@ module Faraday
# client or server error responses. # client or server error responses.
class RaiseError < Middleware class RaiseError < Middleware
# rubocop:disable Naming/ConstantName # rubocop:disable Naming/ConstantName
ClientErrorStatuses = (400...500).freeze ClientErrorStatuses = (400...500)
ServerErrorStatuses = (500...600).freeze ServerErrorStatuses = (500...600)
# rubocop:enable Naming/ConstantName # rubocop:enable Naming/ConstantName
def on_complete(env) def on_complete(env)

View File

@ -25,7 +25,7 @@ module Faraday
attr_writer :default_space_encoding attr_writer :default_space_encoding
end end
ESCAPE_RE = /[^a-zA-Z0-9 .~_-]/.freeze ESCAPE_RE = /[^a-zA-Z0-9 .~_-]/
def escape(str) def escape(str)
str.to_s.gsub(ESCAPE_RE) do |match| str.to_s.gsub(ESCAPE_RE) do |match|
@ -37,7 +37,7 @@ module Faraday
CGI.unescape str.to_s CGI.unescape str.to_s
end end
DEFAULT_SEP = /[&;] */n.freeze DEFAULT_SEP = /[&;] */n
# Adapted from Rack # Adapted from Rack
def parse_query(query) def parse_query(query)

View File

@ -29,14 +29,15 @@ SimpleCov.start do
minimum_coverage_by_file 26 minimum_coverage_by_file 26
end 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 'faraday'
require 'pry' 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.configure do |config|
# rspec-expectations config goes here. You can use an alternate # rspec-expectations config goes here. You can use an alternate