Updated

app/jobs / email_job.rb

B
51 lines of codes
4 methods
4.1 complexity/method
6 churn
16.2 complexity
18 duplications
class EmailJob < ApplicationJob
  1. EmailJob has no descriptive comment
before_perform :set_appsignal_namespace class_attribute :mailer, :email PERMANENT_FAILURES = [ Net::SMTPFatalError, Net::SMTPSyntaxError ] TEMPORARY_FAILURES = [
  1. Identical code found in 2 nodes Locations: 0 1
Net::SMTPAuthenticationError, Net::OpenTimeout, Net::SMTPServerBusy, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, EOFError, SocketError ] queue_as :high_priority rescue_from *PERMANENT_FAILURES do |exception| log_exception(exception) end rescue_from *TEMPORARY_FAILURES do |exception| log_exception(exception) retry_job end def perform(*args) mailer.send(email, *args).deliver_now end private def log_exception(exception) logger.info(log_message(exception)) end def log_message(exception) "#{exception.class.name} while sending email for #{self.class.name}" end def set_appsignal_namespace
  1. EmailJob#set_appsignal_namespace doesn't depend on instance state (maybe move it to another class?)
Appsignal.set_namespace("email") end end