Skip to content

Commit

Permalink
Fixes CodeClimate issues introduced in the latest PRs (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMacTia committed Feb 24, 2019
1 parent 91ddced commit fcc4c40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 473
Max: 489

# Offense count: 5
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 209
Max: 217

# Offense count: 20
Metrics/CyclomaticComplexity:
Expand Down
8 changes: 3 additions & 5 deletions lib/faraday/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class Connection
# @return [Faraday::Builder] Builder for this Connection.
attr_reader :builder

# @return [Hash] request options.
attr_reader :options

# @return [Hash] SSL options.
attr_reader :ssl

Expand Down Expand Up @@ -187,6 +184,7 @@ def #{method}(url = nil, params = nil, headers = nil)
# @return [Faraday::Response]
def options(*args)
return @options if args.size.zero?

url, params, headers = *args
run_request(:options, url, nil, headers) do |request|
request.params.update(params) if params
Expand Down Expand Up @@ -399,7 +397,7 @@ def url_prefix=(url, encoder = nil)
def path_prefix=(value)
url_prefix.path = if value
value = '/' + value unless value[0,1] == '/'
value
value
end
end

Expand Down Expand Up @@ -532,7 +530,7 @@ def proxy_from_env(url)
case url
when String
uri = Utils.URI(url)
uri = URI.parse("#{uri.scheme}://#{uri.hostname}").find_proxy
uri = URI.parse("#{uri.scheme}://#{uri.hostname}").find_proxy
when URI
uri = url.find_proxy
when nil
Expand Down
24 changes: 12 additions & 12 deletions test/live_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ class LiveServer < Sinatra::Base
set :environment, :test
disable :logging
disable :protection

[:get, :post, :put, :patch, :delete, :options].each do |method|
send(method, '/echo') do
kind = request.request_method.downcase
out = kind.dup
out << ' ?' << request.GET.inspect if request.GET.any?
out << ' ' << request.POST.inspect if request.POST.any?

content_type 'text/plain'
return out
end
end

[:get, :post].each do |method|
send(method, '/stream') do
content_type :txt
Expand All @@ -29,7 +29,7 @@ class LiveServer < Sinatra::Base
end
end
end

[:get, :post].each do |method|
send(method, '/empty_stream') do
content_type :txt
Expand All @@ -38,12 +38,12 @@ class LiveServer < Sinatra::Base
end
end
end

get '/echo_header' do
header = "HTTP_#{params[:name].tr('-', '_').upcase}"
request.env.fetch(header) { 'NONE' }
end

post '/file' do
if params[:uploaded_file].respond_to? :each_key
"file %s %s %d" % [
Expand All @@ -55,28 +55,28 @@ class LiveServer < Sinatra::Base
status 400
end
end

get '/multi' do
[200, { 'Set-Cookie' => 'one, two' }, '']
end

get '/who-am-i' do
request.env['REMOTE_ADDR']
end

get '/slow' do
sleep 10
[200, {}, 'ok']
end

get '/204' do
status 204 # no content
end

get '/ssl' do
request.secure?.to_s
end

error do |e|
"#{e.class}\n#{e.to_s}\n#{e.backtrace.join("\n")}"
end
Expand Down

0 comments on commit fcc4c40

Please sign in to comment.