Skip to content

Commit f1762fd

Browse files
authored
🔀 Merge pull request #304 from ruby/fix-ruby-2.7-warnings
🔇 Fix ruby 2.7 warnings
2 parents 958e872 + c921580 commit f1762fd

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

lib/net/imap/config.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Config
126126
def self.default; @default end
127127

128128
# The global config object. Also available from Net::IMAP.config.
129-
def self.global; @global end
129+
def self.global; @global if defined?(@global) end
130130

131131
# A hash of hard-coded configurations, indexed by version number.
132132
def self.version_defaults; @version_defaults end
@@ -149,12 +149,11 @@ def self.version_defaults; @version_defaults end
149149
#
150150
# Given a config, returns that same config.
151151
def self.[](config)
152-
if config.is_a?(Config) || config.nil? && global.nil?
153-
config
154-
elsif config.respond_to?(:to_hash)
155-
new(global, **config).freeze
152+
if config.is_a?(Config) then config
153+
elsif config.nil? && global.nil? then nil
154+
elsif config.respond_to?(:to_hash) then new(global, **config).freeze
156155
else
157-
version_defaults.fetch(config) {
156+
version_defaults.fetch(config) do
158157
case config
159158
when Numeric
160159
raise RangeError, "unknown config version: %p" % [config]
@@ -165,7 +164,7 @@ def self.[](config)
165164
config.class, Config
166165
]
167166
end
168-
}
167+
end
169168
end
170169
end
171170

test/net/imap/test_deprecated_client_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InitializeTests < DeprecatedClientOptionsTest
2424

2525
test "Convert obsolete options hash to keywords" do
2626
run_fake_server_in_thread do |server|
27-
with_client(server.host, {port: server.port, ssl: false}) do |client|
27+
with_client(server.host, {port: server.port, ssl: false}, **{}) do |client|
2828
assert_equal server.host, client.host
2929
assert_equal server.port, client.port
3030
assert_equal false, client.ssl_ctx_params

test/net/imap/test_imap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def tcp_socket(host, port)
523523
t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
524524
}
525525
#super
526-
s = Socket.tcp(host, port, :connect_timeout => @open_timeout)
526+
s = Socket.tcp(host, port)
527527
@@h[:in_tcp_socket_2] = {
528528
s: s.inspect,
529529
local_address: s.local_address,

0 commit comments

Comments
 (0)