Skip to content

Commit 1da8ef9

Browse files
committed
🗑 Add ^category: :deprecated` to calls to warn
This was recommended by @shugo for #97, but we needed to support ruby 2.7 at that time. The minimum required ruby is 3.1 now, so should update our deprecation warnings.
1 parent 3b3f8ae commit 1da8ef9

8 files changed

+23
-13
lines changed

lib/net/imap.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,8 @@ def responses(type = nil)
25452545
when :raise
25462546
raise ArgumentError, "Pass a block or use #clear_responses"
25472547
when :warn
2548-
warn("DEPRECATED: pass a block or use #clear_responses", uplevel: 1)
2548+
warn("DEPRECATED: pass a block or use #clear_responses",
2549+
uplevel: 1, category: :deprecated)
25492550
end
25502551
@responses
25512552
end

lib/net/imap/authenticators.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def add_authenticator(...)
99
"%s.%s is deprecated. Use %s.%s instead." % [
1010
Net::IMAP, __method__, Net::IMAP::SASL, __method__
1111
],
12-
uplevel: 1
12+
uplevel: 1, category: :deprecated
1313
)
1414
Net::IMAP::SASL.add_authenticator(...)
1515
end
@@ -20,7 +20,7 @@ def authenticator(...)
2020
"%s.%s is deprecated. Use %s.%s instead." % [
2121
Net::IMAP, __method__, Net::IMAP::SASL, __method__
2222
],
23-
uplevel: 1
23+
uplevel: 1, category: :deprecated
2424
)
2525
Net::IMAP::SASL.authenticator(...)
2626
end

lib/net/imap/command_data.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def validate
193193

194194
def initialize(data)
195195
@data = data
196-
warn "DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}."
196+
warn("DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}.",
197+
uplevel: 1, category: :deprecated)
197198
begin
198199
# to ensure the input works with SequenceSet, too
199200
SequenceSet.new(data)

lib/net/imap/deprecated_client_options.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def initialize(host, port_or_options = nil, *deprecated, **options)
8383
elsif deprecated.empty?
8484
super host, port: port_or_options
8585
elsif deprecated.shift
86-
warn "DEPRECATED: Call Net::IMAP.new with keyword options", uplevel: 1
86+
warn("DEPRECATED: Call Net::IMAP.new with keyword options",
87+
uplevel: 1, category: :deprecated)
8788
super host, port: port_or_options, ssl: create_ssl_params(*deprecated)
8889
else
89-
warn "DEPRECATED: Call Net::IMAP.new with keyword options", uplevel: 1
90+
warn("DEPRECATED: Call Net::IMAP.new with keyword options",
91+
uplevel: 1, category: :deprecated)
9092
super host, port: port_or_options, ssl: false
9193
end
9294
end
@@ -113,7 +115,8 @@ def starttls(*deprecated, **options)
113115
elsif deprecated.first.respond_to?(:to_hash)
114116
super(**Hash.try_convert(deprecated.first))
115117
else
116-
warn "DEPRECATED: Call Net::IMAP#starttls with keyword options", uplevel: 1
118+
warn("DEPRECATED: Call Net::IMAP#starttls with keyword options",
119+
uplevel: 1, category: :deprecated)
117120
super(**create_ssl_params(*deprecated))
118121
end
119122
end

lib/net/imap/response_data.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ def multipart?
939939
# for something else?
940940
#++
941941
def media_subtype
942-
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
942+
warn("media_subtype is obsolete, use subtype instead.\n",
943+
uplevel: 1, category: :deprecated)
943944
return subtype
944945
end
945946
end
@@ -984,7 +985,8 @@ def multipart?
984985
# generate a warning message to +stderr+, then return
985986
# the value of +subtype+.
986987
def media_subtype
987-
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
988+
warn("media_subtype is obsolete, use subtype instead.\n",
989+
uplevel: 1, category: :deprecated)
988990
return subtype
989991
end
990992
end
@@ -1182,7 +1184,8 @@ def multipart?
11821184
# generate a warning message to +stderr+, then return
11831185
# the value of +subtype+.
11841186
def media_subtype
1185-
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
1187+
warn("media_subtype is obsolete, use subtype instead.\n",
1188+
uplevel: 1, category: :deprecated)
11861189
return subtype
11871190
end
11881191
end

lib/net/imap/sasl/cram_md5_authenticator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def initialize(user = nil, pass = nil,
2020
warn_deprecation: true,
2121
**)
2222
if warn_deprecation
23-
warn "WARNING: CRAM-MD5 mechanism is deprecated." # TODO: recommend SCRAM
23+
warn "WARNING: CRAM-MD5 mechanism is deprecated.", category: :deprecated
2424
end
2525
require "digest/md5"
2626
@user = authcid || username || user

lib/net/imap/sasl/digest_md5_authenticator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def initialize(user = nil, pass = nil, authz = nil,
161161
password ||= secret || pass or raise ArgumentError, "missing password"
162162
authzid ||= authz
163163
if warn_deprecation
164-
warn "WARNING: DIGEST-MD5 SASL mechanism was deprecated by RFC6331."
164+
warn("WARNING: DIGEST-MD5 SASL mechanism was deprecated by RFC6331.",
165+
category: :deprecated)
165166
end
166167

167168
require "digest/md5"

lib/net/imap/sasl/login_authenticator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def initialize(user = nil, pass = nil,
2929
warn_deprecation: true,
3030
**)
3131
if warn_deprecation
32-
warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead."
32+
warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead.",
33+
category: :deprecated
3334
end
3435
@user = authcid || username || user
3536
@password = password || secret || pass

0 commit comments

Comments
 (0)