Skip to content

Commit

Permalink
Fix linting bumping Rubocop to 0.90.0 (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMacTia committed Sep 17, 2020
1 parent 9af091f commit 868fe9b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/adapter/em_http.rb
Expand Up @@ -231,7 +231,7 @@ def running?

def add(&block)
if running?
perform_request { yield }
perform_request(&block)
else
@registered_procs << block
end
Expand Down
6 changes: 3 additions & 3 deletions lib/faraday/connection.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
12 changes: 4 additions & 8 deletions lib/faraday/options.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/rack_builder.rb
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/request/multipart.rb
Expand Up @@ -13,7 +13,7 @@ class Multipart < UrlEncoded
end

def initialize(app = nil, options = {})
@app = app
super(app)
@options = options
end

Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/utils.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/utils/headers.rb
Expand Up @@ -105,7 +105,7 @@ def replace(other)
end

def to_hash
::Hash.new.update(self)
{}.update(self)
end

def parse(header_string)
Expand Down
4 changes: 2 additions & 2 deletions spec/faraday/request/authorization_spec.rb
Expand Up @@ -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"/) }
Expand All @@ -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"') }

Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples/request_method.rb
Expand Up @@ -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
Expand Down

0 comments on commit 868fe9b

Please sign in to comment.