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

style(rubocop): Lint/UselessAssignment

هذا الالتزام موجود في:
Adam Cooke
2024-02-10 17:16:45 +00:00
الأصل 25d7d66b47
التزام 7590a46234
12 ملفات معدلة مع 18 إضافات و20 حذوفات

عرض الملف

@@ -14,7 +14,7 @@ controller :messages do
action do action do
begin begin
message = identity.server.message(params.id) message = identity.server.message(params.id)
rescue Postal::MessageDB::Message::NotFound => e rescue Postal::MessageDB::Message::NotFound
error "MessageNotFound", id: params.id error "MessageNotFound", id: params.id
end end
structure :message, message, return: true structure :message, message, return: true
@@ -30,7 +30,7 @@ controller :messages do
action do action do
begin begin
message = identity.server.message(params.id) message = identity.server.message(params.id)
rescue Postal::MessageDB::Message::NotFound => e rescue Postal::MessageDB::Message::NotFound
error "MessageNotFound", id: params.id error "MessageNotFound", id: params.id
end end
message.deliveries.map do |d| message.deliveries.map do |d|

عرض الملف

@@ -33,7 +33,7 @@ class IPPoolsController < ApplicationController
def destroy def destroy
@ip_pool.destroy @ip_pool.destroy
redirect_to_with_json :ip_pools, notice: "IP pool has been removed successfully." redirect_to_with_json :ip_pools, notice: "IP pool has been removed successfully."
rescue ActiveRecord::DeleteRestrictionError => e rescue ActiveRecord::DeleteRestrictionError
redirect_to_with_json [:edit, @ip_pool], alert: "IP pool cannot be removed because it still has associated addresses or servers." redirect_to_with_json [:edit, @ip_pool], alert: "IP pool cannot be removed because it still has associated addresses or servers."
end end

عرض الملف

@@ -188,7 +188,7 @@ class MessagesController < ApplicationController
if qs[:before] if qs[:before]
begin begin
options[:where][:timestamp][:less_than] = get_time_from_string(qs[:before]).to_f options[:where][:timestamp][:less_than] = get_time_from_string(qs[:before]).to_f
rescue TimeUndetermined => e rescue TimeUndetermined
flash.now[:alert] = "Couldn't determine time for before from '#{qs[:before]}'" flash.now[:alert] = "Couldn't determine time for before from '#{qs[:before]}'"
end end
end end
@@ -196,7 +196,7 @@ class MessagesController < ApplicationController
if qs[:after] if qs[:after]
begin begin
options[:where][:timestamp][:greater_than] = get_time_from_string(qs[:after]).to_f options[:where][:timestamp][:greater_than] = get_time_from_string(qs[:after]).to_f
rescue TimeUndetermined => e rescue TimeUndetermined
flash.now[:alert] = "Couldn't determine time for after from '#{qs[:after]}'" flash.now[:alert] = "Couldn't determine time for after from '#{qs[:after]}'"
end end
end end

عرض الملف

@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
login(User.authenticate(params[:email_address], params[:password])) login(User.authenticate(params[:email_address], params[:password]))
flash[:remember_login] = true flash[:remember_login] = true
redirect_to_with_return_to root_path redirect_to_with_return_to root_path
rescue Postal::Errors::AuthenticationError => e rescue Postal::Errors::AuthenticationError
flash.now[:alert] = "The credentials you've provided are incorrect. Please check and try again." flash.now[:alert] = "The credentials you've provided are incorrect. Please check and try again."
render "new" render "new"
end end

عرض الملف

@@ -26,7 +26,7 @@ class IncomingMessagePrototype
def route def route
@routes ||= if @to.present? @routes ||= if @to.present?
uname, domain = @to.split("@", 2) uname, domain = @to.split("@", 2)
uname, tag = uname.split("+", 2) uname, _tag = uname.split("+", 2)
@server.routes.includes(:domain).where(domains: { name: domain }, name: uname).first @server.routes.includes(:domain).where(domains: { name: domain }, name: uname).first
end end
end end

عرض الملف

@@ -50,7 +50,7 @@ class Organization < ApplicationRecord
has_many :ip_pool_rules, dependent: :destroy, as: :owner has_many :ip_pool_rules, dependent: :destroy, as: :owner
after_create do after_create do
if pool = IPPool.default if IPPool.default
ip_pools << IPPool.default ip_pools << IPPool.default
end end
end end

عرض الملف

@@ -202,7 +202,7 @@ class Route < ApplicationRecord
if route = Route.includes(:domain).where(domains: { name: domain.name }, name: name).where.not(id: id).first if route = Route.includes(:domain).where(domains: { name: domain.name }, name: name).where.not(id: id).first
errors.add :name, "is configured on the #{route.server.full_permalink} mail server" errors.add :name, "is configured on the #{route.server.full_permalink} mail server"
end end
elsif route = Route.where(name: "__returnpath__").where.not(id: id).exists? elsif Route.where(name: "__returnpath__").where.not(id: id).exists?
errors.add :base, "A return path route already exists for this server" errors.add :base, "A return path route already exists for this server"
end end
end end

عرض الملف

@@ -232,8 +232,6 @@ class Server < ApplicationRecord
return nil unless uname return nil unless uname
return nil unless domain_name return nil unless domain_name
uname, = uname.split("+", 2)
# Find a verified domain which directly matches the domain name for the given address. # Find a verified domain which directly matches the domain name for the given address.
domain = Domain.verified domain = Domain.verified
.order(owner_type: :desc) .order(owner_type: :desc)

عرض الملف

@@ -26,7 +26,7 @@ module Postal
message message
end end
n.notify!(short_message: message_without_ansi, log_name: @log_name, facility: "postal", application_name: "postal", process_name: ENV.fetch("PROC_NAME", nil), pid: Process.pid) n.notify!(short_message: message_without_ansi, log_name: @log_name, facility: "postal", application_name: "postal", process_name: ENV.fetch("PROC_NAME", nil), pid: Process.pid)
rescue StandardError => e rescue StandardError
# Can't log this to GELF. Soz. # Can't log this to GELF. Soz.
end end
end end

عرض الملف

@@ -64,29 +64,29 @@ module Postal
code: result.code.to_i, code: result.code.to_i,
body: result.body, body: result.body,
headers: result.to_hash, headers: result.to_hash,
secure: @ssl secure: ssl
} }
end end
rescue OpenSSL::SSL::SSLError => e rescue OpenSSL::SSL::SSLError
{ {
code: -3, code: -3,
body: "Invalid SSL certificate", body: "Invalid SSL certificate",
headers: {}, headers: {},
secure: @ssl secure: ssl
} }
rescue SocketError, Errno::ECONNRESET, EOFError, Errno::EINVAL, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e rescue SocketError, Errno::ECONNRESET, EOFError, Errno::EINVAL, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
{ {
code: -2, code: -2,
body: e.message, body: e.message,
headers: {}, headers: {},
secure: @ssl secure: ssl
} }
rescue Timeout::Error => e rescue Timeout::Error
{ {
code: -1, code: -1,
body: "Timed out after #{timeout}s", body: "Timed out after #{timeout}s",
headers: {}, headers: {},
secure: @ssl secure: ssl
} }
end end
end end

عرض الملف

@@ -40,7 +40,7 @@ module Postal
# Get a statistic (or statistics) # Get a statistic (or statistics)
# #
def get(type, counters, start_date = Time.now, quantity = 10) def get(type, counters, start_date = Time.now, quantity = 10)
date = start_date.utc start_date = start_date.utc
items = quantity.times.each_with_object({}) do |i, hash| items = quantity.times.each_with_object({}) do |i, hash|
hash[(start_date - i.send(STATS_GAPS[type])).send("beginning_of_#{STATS_GAPS[type]}").utc] = counters.each_with_object({}) do |c, h| hash[(start_date - i.send(STATS_GAPS[type])).send("beginning_of_#{STATS_GAPS[type]}").utc] = counters.each_with_object({}) do |c, h|
h[c] = 0 h[c] = 0

عرض الملف

@@ -17,7 +17,7 @@ describe Postal::MessageParser do
it "should replace links in messages" do it "should replace links in messages" do
with_global_server do |server| with_global_server do |server|
message = create_plain_text_message(server, "Hello world! http://github.com/atech/postal", "test@example.com") message = create_plain_text_message(server, "Hello world! http://github.com/atech/postal", "test@example.com")
track_domain = create(:track_domain, server: server, domain: message.domain) create(:track_domain, server: server, domain: message.domain)
parser = Postal::MessageParser.new(message) parser = Postal::MessageParser.new(message)
expect(parser.actioned?).to be true expect(parser.actioned?).to be true
expect(parser.new_body).to match(/^Hello world! https:\/\/click\.#{message.domain.name}/) expect(parser.new_body).to match(/^Hello world! https:\/\/click\.#{message.domain.name}/)