مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
style(rubocop): Style/NumericPredicate
هذا الالتزام موجود في:
@@ -20,7 +20,7 @@ module HasMessage
|
||||
def include_message
|
||||
queued_messages = all.to_a
|
||||
server_ids = queued_messages.map(&:server_id).uniq
|
||||
if server_ids.size == 0
|
||||
if server_ids.empty?
|
||||
return []
|
||||
elsif server_ids.size > 1
|
||||
raise Postal::Error, "'include_message' can only be used on collections of messages from the same server"
|
||||
|
||||
@@ -160,7 +160,7 @@ class Server < ApplicationRecord
|
||||
total_outgoing += stat[:outgoing]
|
||||
total_bounces += stat[:bounces]
|
||||
end
|
||||
total_outgoing == 0 ? 0 : (total_bounces / total_outgoing) * 100
|
||||
total_outgoing.zero? ? 0 : (total_bounces / total_outgoing) * 100
|
||||
end
|
||||
end
|
||||
|
||||
@@ -221,7 +221,7 @@ class Server < ApplicationRecord
|
||||
|
||||
# Return the domain which can be used to authenticate emails sent from the given e-mail address.
|
||||
#
|
||||
# @param address [String] an e-mail address
|
||||
# @param address [String] an e-mail address
|
||||
# @return [Domain, nil] the domain to use for authentication
|
||||
def authenticated_domain_for_address(address)
|
||||
return nil if address.blank?
|
||||
|
||||
@@ -17,7 +17,7 @@ module Postal
|
||||
def self.request(method, url, options = {})
|
||||
options[:headers] ||= {}
|
||||
uri = URI.parse(url)
|
||||
request = method.new((uri.path.length == 0 ? "/" : uri.path) + (uri.query ? "?" + uri.query : ""))
|
||||
request = method.new((uri.path.empty? ? "/" : uri.path) + (uri.query ? "?" + uri.query : ""))
|
||||
options[:headers].each { |k, v| request.add_field k, v }
|
||||
|
||||
if options[:username] || uri.user
|
||||
|
||||
@@ -40,7 +40,7 @@ module Postal
|
||||
# This is temporary. They might fix their server so it should soft fail.
|
||||
result.type = "SoftFail"
|
||||
result.retry = true
|
||||
elsif response[:code] < 0
|
||||
elsif response[:code].negative?
|
||||
# Connection/SSL etc... errors
|
||||
result.type = "SoftFail"
|
||||
result.retry = true
|
||||
|
||||
@@ -196,7 +196,7 @@ module Postal
|
||||
result[:records] = select(table, options.merge(limit: per_page, offset: offset))
|
||||
result[:per_page] = per_page
|
||||
result[:total_pages], remainder = result[:total].divmod(per_page)
|
||||
result[:total_pages] += 1 if remainder > 0
|
||||
result[:total_pages] += 1 if remainder.positive?
|
||||
result[:page] = page
|
||||
result
|
||||
end
|
||||
@@ -308,7 +308,7 @@ module Postal
|
||||
"0"
|
||||
elsif value.nil?
|
||||
"NULL"
|
||||
elsif value.to_s.length == 0
|
||||
elsif value.to_s.empty?
|
||||
"NULL"
|
||||
else
|
||||
"'" + mysql.escape(value.to_s) + "'"
|
||||
|
||||
@@ -28,7 +28,7 @@ module Postal
|
||||
end
|
||||
|
||||
def remove(type, address)
|
||||
@database.delete("suppressions", where: { type: type, address: address }) > 0
|
||||
@database.delete("suppressions", where: { type: type, address: address }).positive?
|
||||
end
|
||||
|
||||
def prune
|
||||
|
||||
@@ -21,7 +21,7 @@ module Postal
|
||||
attr_reader :tracked_images
|
||||
|
||||
def actioned?
|
||||
@actioned || @tracked_links > 0 || @tracked_images > 0
|
||||
@actioned || @tracked_links.positive? || @tracked_images.positive?
|
||||
end
|
||||
|
||||
def new_body
|
||||
|
||||
@@ -163,7 +163,7 @@ module Postal
|
||||
case io
|
||||
when OpenSSL::SSL::SSLSocket
|
||||
buffers[io] << io.readpartial(10_240)
|
||||
buffers[io] << io.readpartial(10_240) while io.pending > 0
|
||||
buffers[io] << io.readpartial(10_240) while io.pending.positive?
|
||||
else
|
||||
buffers[io] << io.readpartial(10_240)
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module Postal
|
||||
logger.info "Job did not finish in a timely manner. Exiting"
|
||||
exit 0
|
||||
end
|
||||
if exit_checks == 0
|
||||
if exit_checks.zero?
|
||||
logger.info "Exit requested but job is running. Waiting for job to finish."
|
||||
end
|
||||
sleep 60
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم