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

🗑 Add category: :deprecated to calls to warn #322

Merged
merged 1 commit into from
Sep 16, 2024
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
3 changes: 2 additions & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,8 @@ def responses(type = nil)
when :raise
raise ArgumentError, "Pass a block or use #clear_responses"
when :warn
warn("DEPRECATED: pass a block or use #clear_responses", uplevel: 1)
warn("DEPRECATED: pass a block or use #clear_responses",
uplevel: 1, category: :deprecated)
end
@responses
end
Expand Down
4 changes: 2 additions & 2 deletions lib/net/imap/authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def add_authenticator(...)
"%s.%s is deprecated. Use %s.%s instead." % [
Net::IMAP, __method__, Net::IMAP::SASL, __method__
],
uplevel: 1
uplevel: 1, category: :deprecated
)
Net::IMAP::SASL.add_authenticator(...)
end
Expand All @@ -20,7 +20,7 @@ def authenticator(...)
"%s.%s is deprecated. Use %s.%s instead." % [
Net::IMAP, __method__, Net::IMAP::SASL, __method__
],
uplevel: 1
uplevel: 1, category: :deprecated
)
Net::IMAP::SASL.authenticator(...)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/net/imap/command_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def validate

def initialize(data)
@data = data
warn "DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}."
warn("DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}.",
uplevel: 1, category: :deprecated)
begin
# to ensure the input works with SequenceSet, too
SequenceSet.new(data)
Expand Down
9 changes: 6 additions & 3 deletions lib/net/imap/deprecated_client_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ def initialize(host, port_or_options = nil, *deprecated, **options)
elsif deprecated.empty?
super host, port: port_or_options
elsif deprecated.shift
warn "DEPRECATED: Call Net::IMAP.new with keyword options", uplevel: 1
warn("DEPRECATED: Call Net::IMAP.new with keyword options",
uplevel: 1, category: :deprecated)
super host, port: port_or_options, ssl: create_ssl_params(*deprecated)
else
warn "DEPRECATED: Call Net::IMAP.new with keyword options", uplevel: 1
warn("DEPRECATED: Call Net::IMAP.new with keyword options",
uplevel: 1, category: :deprecated)
super host, port: port_or_options, ssl: false
end
end
Expand All @@ -113,7 +115,8 @@ def starttls(*deprecated, **options)
elsif deprecated.first.respond_to?(:to_hash)
super(**Hash.try_convert(deprecated.first))
else
warn "DEPRECATED: Call Net::IMAP#starttls with keyword options", uplevel: 1
warn("DEPRECATED: Call Net::IMAP#starttls with keyword options",
uplevel: 1, category: :deprecated)
super(**create_ssl_params(*deprecated))
end
end
Expand Down
9 changes: 6 additions & 3 deletions lib/net/imap/response_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ def multipart?
# for something else?
#++
def media_subtype
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
warn("media_subtype is obsolete, use subtype instead.\n",
uplevel: 1, category: :deprecated)
return subtype
end
end
Expand Down Expand Up @@ -984,7 +985,8 @@ def multipart?
# generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
warn("media_subtype is obsolete, use subtype instead.\n",
uplevel: 1, category: :deprecated)
return subtype
end
end
Expand Down Expand Up @@ -1182,7 +1184,8 @@ def multipart?
# generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
warn("media_subtype is obsolete, use subtype instead.\n", uplevel: 1)
warn("media_subtype is obsolete, use subtype instead.\n",
uplevel: 1, category: :deprecated)
return subtype
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/net/imap/sasl/cram_md5_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(user = nil, pass = nil,
warn_deprecation: true,
**)
if warn_deprecation
warn "WARNING: CRAM-MD5 mechanism is deprecated." # TODO: recommend SCRAM
warn "WARNING: CRAM-MD5 mechanism is deprecated.", category: :deprecated
end
require "digest/md5"
@user = authcid || username || user
Expand Down
3 changes: 2 additions & 1 deletion lib/net/imap/sasl/digest_md5_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def initialize(user = nil, pass = nil, authz = nil,
password ||= secret || pass or raise ArgumentError, "missing password"
authzid ||= authz
if warn_deprecation
warn "WARNING: DIGEST-MD5 SASL mechanism was deprecated by RFC6331."
warn("WARNING: DIGEST-MD5 SASL mechanism was deprecated by RFC6331.",
category: :deprecated)
end

require "digest/md5"
Expand Down
3 changes: 2 additions & 1 deletion lib/net/imap/sasl/login_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def initialize(user = nil, pass = nil,
warn_deprecation: true,
**)
if warn_deprecation
warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead."
warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead.",
category: :deprecated
end
@user = authcid || username || user
@password = password || secret || pass
Expand Down