Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Ruby 3.0 the min version #1544

Merged
merged 6 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby 2.7
- name: Setup Ruby 3.x
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3
bundler-cache: true

- name: Rubocop
Expand All @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
ruby: [ '3.0', '3.1', '3.2', '3.3' ]
experimental: [false]
include:
- ruby: head
Expand All @@ -63,7 +63,6 @@ jobs:
run: bundle exec rake

- name: Test External Adapters
if: ${{ matrix.ruby != '2.6' }}
continue-on-error: ${{ matrix.experimental }}
run: bundle exec bake test:external

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby 2.7
- name: Setup Ruby 3.x
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3

- name: Publish to RubyGems
uses: dawidd6/action-publish-gem@v1
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Expand Up @@ -7,7 +7,7 @@ require:
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0
iMacTia marked this conversation as resolved.
Show resolved Hide resolved

# Custom config
Gemspec/RequireMFA: # we don't know if this works with auto-deployments yet
Expand Down
31 changes: 21 additions & 10 deletions .rubocop_todo.yml
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not completely relevant, but, I guess, acceptable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp maybe not, I agree, but the RuboCop version can be useful 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm generally talking more about RuboCop itself… the PR is about minimal Ruby version, and there are RuboCop updates. But it's up to you, I'm not against it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, good point. I've limited changes to those necessary after increasing the TargetRubyVersion rubocop config from 2.6 to 3.0. This change was required because Rubocop needs that to be the same as the Gemspec's required_ruby_version. After that some new offences popped up

# 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 README.md
Expand Up @@ -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
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).
Currently that means we support Ruby 2.6+
Currently that means we support Ruby 3.0+
iMacTia marked this conversation as resolved.
Show resolved Hide resolved

If something doesn't work on one of these Ruby versions, it's a bug.

Expand Down
3 changes: 1 addition & 2 deletions faraday.gemspec
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://lostisland.github.io/faraday'
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
# control which version of faraday it will be pulled from.
Expand All @@ -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
# 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 'ruby2_keywords', '>= 0.0.4'

# 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']
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/connection.rb
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
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
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
1 change: 0 additions & 1 deletion lib/faraday/rack_builder.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'ruby2_keywords'
require 'faraday/adapter_registry'

module Faraday
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/request/json.rb
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
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
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
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'
iMacTia marked this conversation as resolved.
Show resolved Hide resolved
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