Updated

app/mailers/archived / petition_mailer.rb

F
107 lines of codes
12 methods
6.6 complexity/method
4 churn
79.2 complexity
216 duplications
module Archived class PetitionMailer < ApplicationMailer
  1. Archived::PetitionMailer assumes too much for instance variable '@debate_outcome'
  2. Archived::PetitionMailer assumes too much for instance variable '@email'
  3. Archived::PetitionMailer assumes too much for instance variable '@petition'
  4. Archived::PetitionMailer assumes too much for instance variable '@signature'
  5. Archived::PetitionMailer has no descriptive comment
  6. Archived::PetitionMailer has at least 6 instance variables
include ActiveSupport::NumberHelper def email_signer(petition, signature, email)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature, @email = petition, signature, email mail to: @signature.email, subject: subject_for(:email_signer), list_unsubscribe: unsubscribe_url end def email_creator(petition, signature, email)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature, @email = petition, signature, email mail to: @signature.email, subject: subject_for(:email_creator), list_unsubscribe: unsubscribe_url end def notify_signer_of_threshold_response(petition, signature)
  1. Similar code found in 2 nodes Locations: 0 1
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature = petition, signature @government_response, @parliament = petition.government_response, petition.parliament mail to: @signature.email, subject: subject_for(:notify_signer_of_threshold_response), list_unsubscribe: unsubscribe_url end def notify_creator_of_threshold_response(petition, signature)
  1. Similar code found in 2 nodes Locations: 0 1
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature = petition, signature @government_response, @parliament = petition.government_response, petition.parliament mail to: @signature.email, subject: subject_for(:notify_creator_of_threshold_response), list_unsubscribe: unsubscribe_url end def notify_signer_of_debate_scheduled(petition, signature)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature = petition, signature mail to: @signature.email, subject: subject_for(:notify_signer_of_debate_scheduled), list_unsubscribe: unsubscribe_url end def notify_creator_of_debate_scheduled(petition, signature)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @signature = petition, signature mail to: @signature.email, subject: subject_for(:notify_creator_of_debate_scheduled), list_unsubscribe: unsubscribe_url end def notify_signer_of_debate_outcome(petition, signature)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature if @debate_outcome.debated? subject = subject_for(:notify_signer_of_positive_debate_outcome) else subject = subject_for(:notify_signer_of_negative_debate_outcome) end mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url end def notify_creator_of_debate_outcome(petition, signature)
  1. Similar code found in 4 nodes Locations: 0 1 2 3
  2. Archived::PetitionMailer takes parameters ['petition', 'signature'] to 8 methods Locations: 0 1 2 3 4 5 6 7
@petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature if @debate_outcome.debated? subject = subject_for(:notify_creator_of_positive_debate_outcome) else subject = subject_for(:notify_creator_of_negative_debate_outcome) end mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url end private def subject_for(key, options = {}) I18n.t key, i18n_options.merge(options) end def signature_belongs_to_creator? @signature && @signature.creator? end def i18n_options
  1. Archived::PetitionMailer#i18n_options has approx 6 statements
{}.tap do |options| options[:scope] = :"petitions.emails.subjects" if defined?(@petition)
  1. Identical code found in 2 nodes Locations: 0 1
options[:count] = @petition.signature_count
  1. Archived::PetitionMailer#i18n_options calls '@petition.signature_count' 2 times Locations: 0 1
options[:formatted_count] = number_to_delimited(@petition.signature_count)
  1. Archived::PetitionMailer#i18n_options calls '@petition.signature_count' 2 times Locations: 0 1
options[:action] = @petition.action end if defined?(@email) options[:subject] = @email.subject end end end def unsubscribe_url "<#{unsubscribe_archived_signature_url(@signature, token: @signature.unsubscribe_token)}>" end end end