Skip to content

Commit

Permalink
style(rubocop): Lint/UselessAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Feb 10, 2024
1 parent 25d7d66 commit 7590a46
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions api/controllers/messages_api_controller.rb
Expand Up @@ -14,7 +14,7 @@
action do
begin
message = identity.server.message(params.id)
rescue Postal::MessageDB::Message::NotFound => e
rescue Postal::MessageDB::Message::NotFound
error "MessageNotFound", id: params.id
end
structure :message, message, return: true
Expand All @@ -30,7 +30,7 @@
action do
begin
message = identity.server.message(params.id)
rescue Postal::MessageDB::Message::NotFound => e
rescue Postal::MessageDB::Message::NotFound
error "MessageNotFound", id: params.id
end
message.deliveries.map do |d|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ip_pools_controller.rb
Expand Up @@ -33,7 +33,7 @@ def update
def destroy
@ip_pool.destroy
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."
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/messages_controller.rb
Expand Up @@ -188,15 +188,15 @@ def get_messages(scope)
if qs[:before]
begin
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]}'"
end
end

if qs[:after]
begin
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]}'"
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Expand Up @@ -10,7 +10,7 @@ def create
login(User.authenticate(params[:email_address], params[:password]))
flash[:remember_login] = true
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."
render "new"
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/incoming_message_prototype.rb
Expand Up @@ -26,7 +26,7 @@ def from_address
def route
@routes ||= if @to.present?
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
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization.rb
Expand Up @@ -50,7 +50,7 @@ class Organization < ApplicationRecord
has_many :ip_pool_rules, dependent: :destroy, as: :owner

after_create do
if pool = IPPool.default
if IPPool.default
ip_pools << IPPool.default
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/route.rb
Expand Up @@ -202,7 +202,7 @@ def validate_name_uniqueness
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"
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"
end
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/server.rb
Expand Up @@ -232,8 +232,6 @@ def authenticated_domain_for_address(address)
return nil unless uname
return nil unless domain_name

uname, = uname.split("+", 2)

# Find a verified domain which directly matches the domain name for the given address.
domain = Domain.verified
.order(owner_type: :desc)
Expand Down
2 changes: 1 addition & 1 deletion lib/postal/app_logger.rb
Expand Up @@ -26,7 +26,7 @@ def add(severity, message = nil, progname = nil)
message
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)
rescue StandardError => e
rescue StandardError
# Can't log this to GELF. Soz.
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/postal/http.rb
Expand Up @@ -64,29 +64,29 @@ def self.request(method, url, options = {})
code: result.code.to_i,
body: result.body,
headers: result.to_hash,
secure: @ssl
secure: ssl
}
end
rescue OpenSSL::SSL::SSLError => e
rescue OpenSSL::SSL::SSLError
{
code: -3,
body: "Invalid SSL certificate",
headers: {},
secure: @ssl
secure: ssl
}
rescue SocketError, Errno::ECONNRESET, EOFError, Errno::EINVAL, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e
{
code: -2,
body: e.message,
headers: {},
secure: @ssl
secure: ssl
}
rescue Timeout::Error => e
rescue Timeout::Error
{
code: -1,
body: "Timed out after #{timeout}s",
headers: {},
secure: @ssl
secure: ssl
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/postal/message_db/statistics.rb
Expand Up @@ -40,7 +40,7 @@ def increment_all(time, field)
# Get a statistic (or statistics)
#
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|
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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/postal/message_parser_spec.rb
Expand Up @@ -17,7 +17,7 @@
it "should replace links in messages" do
with_global_server do |server|
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)
expect(parser.actioned?).to be true
expect(parser.new_body).to match(/^Hello world! https:\/\/click\.#{message.domain.name}/)
Expand Down

0 comments on commit 7590a46

Please sign in to comment.