Updated

app/jobs / notify_everyone_of_moderation_decision_job.rb

A
34 lines of codes
3 methods
5.4 complexity/method
4 churn
16.18 complexity
0 duplications
class NotifyEveryoneOfModerationDecisionJob < ApplicationJob
  1. NotifyEveryoneOfModerationDecisionJob has no descriptive comment
rescue_from StandardError do |exception| Appsignal.send_exception exception end def perform(petition) creator = petition.creator
  1. NotifyEveryoneOfModerationDecisionJob#perform refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3
sponsors = petition.sponsors.validated
  1. NotifyEveryoneOfModerationDecisionJob#perform refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3
if petition.published?
  1. NotifyEveryoneOfModerationDecisionJob#perform refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3
notify_everyone_of_publication(creator, sponsors) elsif petition.rejected? || petition.hidden?
  1. NotifyEveryoneOfModerationDecisionJob#perform refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3
notify_everyone_of_rejection(creator, sponsors) end end private def notify_everyone_of_publication(creator, sponsors)
  1. NotifyEveryoneOfModerationDecisionJob#notify_everyone_of_publication doesn't depend on instance state (maybe move it to another class?)
NotifyCreatorThatPetitionIsPublishedEmailJob.perform_later(creator) sponsors.each do |sponsor| NotifySponsorThatPetitionIsPublishedEmailJob.perform_later(sponsor) end end def notify_everyone_of_rejection(creator, sponsors)
  1. NotifyEveryoneOfModerationDecisionJob#notify_everyone_of_rejection doesn't depend on instance state (maybe move it to another class?)
NotifyCreatorThatPetitionWasRejectedEmailJob.perform_later(creator) sponsors.each do |sponsor| NotifySponsorThatPetitionWasRejectedEmailJob.perform_later(sponsor) end end end