chore: Rubocop lint Style/UnlessElse

This commit is contained in:
iMacTia 2019-02-28 17:23:33 +00:00
parent 127555abcf
commit e35c49efa8
3 changed files with 20 additions and 29 deletions

View File

@ -609,13 +609,6 @@ Style/TrivialAccessors:
Exclude:
- 'lib/faraday/utils/headers.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/UnlessElse:
Exclude:
- 'lib/faraday/adapter/em_http.rb'
- 'lib/faraday/adapter/em_http_ssl_patch.rb'
# Offense count: 272
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https

View File

@ -107,29 +107,27 @@ module Faraday
perform_single_request(env)
.callback { env[:response].finish(env) }
}
elsif EventMachine.reactor_running?
# EM is running: instruct upstream that this is an async request
env[:parallel_manager] = true
perform_single_request(env)
.callback { env[:response].finish(env) }
.errback {
# TODO: no way to communicate the error in async mode
raise NotImplementedError
}
else
unless EventMachine.reactor_running?
error = nil
# start EM, block until request is completed
EventMachine.run do
perform_single_request(env)
.callback { EventMachine.stop }
.errback { |client|
error = error_message(client)
EventMachine.stop
}
end
raise_error(error) if error
else
# EM is running: instruct upstream that this is an async request
env[:parallel_manager] = true
error = nil
# start EM, block until request is completed
EventMachine.run do
perform_single_request(env)
.callback { env[:response].finish(env) }
.errback {
# TODO: no way to communicate the error in async mode
raise NotImplementedError
.callback { EventMachine.stop }
.errback { |client|
error = error_message(client)
EventMachine.stop
}
end
raise_error(error) if error
end
rescue EventMachine::Connectify::CONNECTError => err
if err.message.include?('Proxy Authentication Required')

View File

@ -30,10 +30,10 @@ module EmHttpSslPatch
def ssl_handshake_completed
return true unless verify_peer?
unless OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, host)
raise OpenSSL::SSL::SSLError.new(%(host "#{host}" does not match the server certificate))
else
if OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, host)
true
else
raise OpenSSL::SSL::SSLError.new(%(host "#{host}" does not match the server certificate))
end
end