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

Fully qualify constants to be checked #1122

Merged
merged 4 commits into from
Feb 7, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/faraday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def self.default_connection_options=(options)
@default_connection_options = ConnectionOptions.from(options)
end

unless const_defined? :Timer
unless defined?(::Faraday::Timer)
require 'timeout'
Timer = Timeout
end
Expand Down
3 changes: 2 additions & 1 deletion lib/faraday/adapter/em_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def perform_request(env)

raise Faraday::ConnectionFailed, e
rescue StandardError => e
if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
if defined?(::OpenSSL::SSL::SSLError) && \
e.is_a?(::OpenSSL::SSL::SSLError)
raise Faraday::SSLError, e
end

Expand Down
3 changes: 2 additions & 1 deletion lib/faraday/adapter/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def call(env)
rescue Errno::EADDRNOTAVAIL, Errno::ECONNREFUSED, IOError, SocketError
raise Faraday::ConnectionFailed, $ERROR_INFO
rescue StandardError => e
if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
if defined?(::OpenSSL::SSL::SSLError) && \
e.is_a?(::OpenSSL::SSL::SSLError)
raise Faraday::SSLError, e
end

Expand Down
6 changes: 4 additions & 2 deletions lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class NetHttp < Faraday::Adapter
Zlib::GzipFile::Error
]

exceptions << OpenSSL::SSL::SSLError if defined?(OpenSSL)
exceptions << Net::OpenTimeout if defined?(Net::OpenTimeout)
if defined?(::OpenSSL::SSL::SSLError)
exceptions << ::OpenSSL::SSL::SSLError
end
exceptions << ::Net::OpenTimeout if defined?(::Net::OpenTimeout)

NET_HTTP_EXCEPTIONS = exceptions.freeze

Expand Down
4 changes: 3 additions & 1 deletion lib/faraday/request/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module Faraday
class Request
# Request middleware for the Authorization HTTP header
class Authorization < Faraday::Middleware
KEY = 'Authorization' unless defined? KEY
unless defined?(::Faraday::Request::Authorization::KEY)
KEY = 'Authorization'
end

# @param type [String, Symbol]
# @param token [String, Symbol, Hash]
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/request/multipart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Request
# Middleware for supporting multi-part requests.
class Multipart < UrlEncoded
self.mime_type = 'multipart/form-data'
unless defined? DEFAULT_BOUNDARY_PREFIX
unless defined?(::Faraday::Request::Multipart::DEFAULT_BOUNDARY_PREFIX)
DEFAULT_BOUNDARY_PREFIX = '-----------RubyMultipartPost'
end

Expand Down
4 changes: 3 additions & 1 deletion lib/faraday/request/url_encoded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module Faraday
class Request
# Middleware for supporting urlencoded requests.
class UrlEncoded < Faraday::Middleware
CONTENT_TYPE = 'Content-Type' unless defined? CONTENT_TYPE
unless defined?(::Faraday::Request::UrlEncoded::CONTENT_TYPE)
CONTENT_TYPE = 'Content-Type'
end

class << self
attr_accessor :mime_type
Expand Down