1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-12-01 05:43:04 +00:00

style(rubocop): Style/NumericPredicate

هذا الالتزام موجود في:
Adam Cooke
2024-02-10 22:59:30 +00:00
الأصل 7119e8642d
التزام c558f1c69c
9 ملفات معدلة مع 11 إضافات و11 حذوفات

عرض الملف

@@ -20,7 +20,7 @@ module HasMessage
def include_message def include_message
queued_messages = all.to_a queued_messages = all.to_a
server_ids = queued_messages.map(&:server_id).uniq server_ids = queued_messages.map(&:server_id).uniq
if server_ids.size == 0 if server_ids.empty?
return [] return []
elsif server_ids.size > 1 elsif server_ids.size > 1
raise Postal::Error, "'include_message' can only be used on collections of messages from the same server" 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_outgoing += stat[:outgoing]
total_bounces += stat[:bounces] total_bounces += stat[:bounces]
end end
total_outgoing == 0 ? 0 : (total_bounces / total_outgoing) * 100 total_outgoing.zero? ? 0 : (total_bounces / total_outgoing) * 100
end end
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. # 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 # @return [Domain, nil] the domain to use for authentication
def authenticated_domain_for_address(address) def authenticated_domain_for_address(address)
return nil if address.blank? return nil if address.blank?

عرض الملف

@@ -17,7 +17,7 @@ module Postal
def self.request(method, url, options = {}) def self.request(method, url, options = {})
options[:headers] ||= {} options[:headers] ||= {}
uri = URI.parse(url) 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 } options[:headers].each { |k, v| request.add_field k, v }
if options[:username] || uri.user if options[:username] || uri.user

عرض الملف

@@ -40,7 +40,7 @@ module Postal
# This is temporary. They might fix their server so it should soft fail. # This is temporary. They might fix their server so it should soft fail.
result.type = "SoftFail" result.type = "SoftFail"
result.retry = true result.retry = true
elsif response[:code] < 0 elsif response[:code].negative?
# Connection/SSL etc... errors # Connection/SSL etc... errors
result.type = "SoftFail" result.type = "SoftFail"
result.retry = true result.retry = true

عرض الملف

@@ -196,7 +196,7 @@ module Postal
result[:records] = select(table, options.merge(limit: per_page, offset: offset)) result[:records] = select(table, options.merge(limit: per_page, offset: offset))
result[:per_page] = per_page result[:per_page] = per_page
result[:total_pages], remainder = result[:total].divmod(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[:page] = page
result result
end end
@@ -308,7 +308,7 @@ module Postal
"0" "0"
elsif value.nil? elsif value.nil?
"NULL" "NULL"
elsif value.to_s.length == 0 elsif value.to_s.empty?
"NULL" "NULL"
else else
"'" + mysql.escape(value.to_s) + "'" "'" + mysql.escape(value.to_s) + "'"

عرض الملف

@@ -28,7 +28,7 @@ module Postal
end end
def remove(type, address) def remove(type, address)
@database.delete("suppressions", where: { type: type, address: address }) > 0 @database.delete("suppressions", where: { type: type, address: address }).positive?
end end
def prune def prune

عرض الملف

@@ -21,7 +21,7 @@ module Postal
attr_reader :tracked_images attr_reader :tracked_images
def actioned? def actioned?
@actioned || @tracked_links > 0 || @tracked_images > 0 @actioned || @tracked_links.positive? || @tracked_images.positive?
end end
def new_body def new_body

عرض الملف

@@ -163,7 +163,7 @@ module Postal
case io case io
when OpenSSL::SSL::SSLSocket when OpenSSL::SSL::SSLSocket
buffers[io] << io.readpartial(10_240) 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 else
buffers[io] << io.readpartial(10_240) buffers[io] << io.readpartial(10_240)
end end

عرض الملف

@@ -35,7 +35,7 @@ module Postal
logger.info "Job did not finish in a timely manner. Exiting" logger.info "Job did not finish in a timely manner. Exiting"
exit 0 exit 0
end end
if exit_checks == 0 if exit_checks.zero?
logger.info "Exit requested but job is running. Waiting for job to finish." logger.info "Exit requested but job is running. Waiting for job to finish."
end end
sleep 60 sleep 60