diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bd428906..702e9c73f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Ruby 2.6 + - name: Set up Ruby 2.7 uses: actions/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: 2.7.x - name: Rubocop run: | @@ -53,7 +53,7 @@ jobs: - name: Set up RVM run: | curl -sSL https://get.rvm.io | bash - + - name: Set up Ruby run: | source $HOME/.rvm/scripts/rvm diff --git a/Gemfile b/Gemfile index 8ac63ce90..45aee7dbf 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ group :development, :test do end group :lint, :development do - gem 'rubocop', '~> 0.84.0' + gem 'rubocop', '~> 0.90.0' gem 'rubocop-performance', '~> 1.0' end diff --git a/lib/faraday/adapter/em_http.rb b/lib/faraday/adapter/em_http.rb index 156da5a52..f2d98c585 100644 --- a/lib/faraday/adapter/em_http.rb +++ b/lib/faraday/adapter/em_http.rb @@ -231,7 +231,7 @@ def running? def add(&block) if running? - perform_request { yield } + perform_request(&block) else @registered_procs << block end diff --git a/lib/faraday/connection.rb b/lib/faraday/connection.rb index e2ef528f0..3776253ee 100644 --- a/lib/faraday/connection.rb +++ b/lib/faraday/connection.rb @@ -429,7 +429,7 @@ def url_prefix=(url, encoder = nil) # @return [String] the new path prefix def path_prefix=(value) url_prefix.path = if value - value = '/' + value unless value[0, 1] == '/' + value = "/#{value}" unless value[0, 1] == '/' value end end @@ -520,7 +520,7 @@ def build_exclusive_url(url = nil, params = nil, params_encoder = nil) base = url_prefix if url && base.path && base.path !~ %r{/$} base = base.dup - base.path = base.path + '/' # ensure trailing slash + base.path = "#{base.path}/" # ensure trailing slash end uri = url ? base + url : base if params @@ -593,7 +593,7 @@ def find_default_proxy uri = ENV['http_proxy'] return unless uri && !uri.empty? - uri = 'http://' + uri unless uri.match?(/^http/i) + uri = "http://#{uri}" unless uri.match?(/^http/i) uri end diff --git a/lib/faraday/options.rb b/lib/faraday/options.rb index b5af43d1b..ee198d8df 100644 --- a/lib/faraday/options.rb +++ b/lib/faraday/options.rb @@ -103,12 +103,10 @@ def empty? end # Public - def each_key + def each_key(&block) return to_enum(:each_key) unless block_given? - keys.each do |key| - yield(key) - end + keys.each(&block) end # Public @@ -119,12 +117,10 @@ def key?(key) alias has_key? key? # Public - def each_value + def each_value(&block) return to_enum(:each_value) unless block_given? - values.each do |value| - yield(value) - end + values.each(&block) end # Public diff --git a/lib/faraday/rack_builder.rb b/lib/faraday/rack_builder.rb index 33ba562c3..42da63478 100644 --- a/lib/faraday/rack_builder.rb +++ b/lib/faraday/rack_builder.rb @@ -232,7 +232,7 @@ def adapter_set? end def is_adapter?(klass) # rubocop:disable Naming/PredicateName - klass.ancestors.include?(Faraday::Adapter) + klass <= Faraday::Adapter end ruby2_keywords def use_symbol(mod, key, *args, &block) diff --git a/lib/faraday/request/multipart.rb b/lib/faraday/request/multipart.rb index 25169f08b..1f96c8d96 100644 --- a/lib/faraday/request/multipart.rb +++ b/lib/faraday/request/multipart.rb @@ -13,7 +13,7 @@ class Multipart < UrlEncoded end def initialize(app = nil, options = {}) - @app = app + super(app) @options = options end diff --git a/lib/faraday/utils.rb b/lib/faraday/utils.rb index 45545d150..b052f9b2f 100644 --- a/lib/faraday/utils.rb +++ b/lib/faraday/utils.rb @@ -28,7 +28,7 @@ class << self def escape(str) str.to_s.gsub(ESCAPE_RE) do |match| - '%' + match.unpack('H2' * match.bytesize).join('%').upcase + "%#{match.unpack('H2' * match.bytesize).join('%').upcase}" end.gsub(' ', default_space_encoding) end @@ -89,7 +89,7 @@ def default_uri_parser=(parser) # the path with the query string sorted. def normalize_path(url) url = URI(url) - (url.path.start_with?('/') ? url.path : '/' + url.path) + + (url.path.start_with?('/') ? url.path : "/#{url.path}") + (url.query ? "?#{sort_query_params(url.query)}" : '') end diff --git a/lib/faraday/utils/headers.rb b/lib/faraday/utils/headers.rb index 9daef87e5..9883dc24c 100644 --- a/lib/faraday/utils/headers.rb +++ b/lib/faraday/utils/headers.rb @@ -105,7 +105,7 @@ def replace(other) end def to_hash - ::Hash.new.update(self) + {}.update(self) end def parse(header_string) diff --git a/spec/faraday/request/authorization_spec.rb b/spec/faraday/request/authorization_spec.rb index 85026d926..3f13392e6 100644 --- a/spec/faraday/request/authorization_spec.rb +++ b/spec/faraday/request/authorization_spec.rb @@ -56,7 +56,7 @@ end context 'when other values are provided' do - let(:auth_config) { ['baz', foo: 42] } + let(:auth_config) { ['baz', { foo: 42 }] } it { expect(response.body).to match(/^Token /) } it { expect(response.body).to match(/token="baz"/) } @@ -78,7 +78,7 @@ end context 'when passed a string and a hash' do - let(:auth_config) { ['baz', foo: 42] } + let(:auth_config) { ['baz', { foo: 42 }] } it { expect(response.body).to eq('baz foo="42"') } diff --git a/spec/support/shared_examples/request_method.rb b/spec/support/shared_examples/request_method.rb index 917e48ca9..05257ff6f 100644 --- a/spec/support/shared_examples/request_method.rb +++ b/spec/support/shared_examples/request_method.rb @@ -119,7 +119,7 @@ request_stub.with(headers: { 'Content-Type' => %r{\Amultipart/form-data} }) do |request| # WebMock does not support matching body for multipart/form-data requests yet :( # https://github.com/bblimke/webmock/issues/623 - request.body =~ /RubyMultipartPost/ + request.body.include?('RubyMultipartPost') end conn.public_send(http_method, '/', payload) end