Updated

app/jobs / notify_trending_ip_job.rb

B
54 lines of codes
9 methods
4.4 complexity/method
3 churn
39.34 complexity
27 duplications
require 'slack-notifier' class NotifyTrendingIpJob < ApplicationJob
  1. NotifyTrendingIpJob has no descriptive comment
include Rails.application.routes.url_helpers queue_as :low_priority delegate :trending_items_notification_url, to: :rate_limit def perform(ip) slack.ping(message(ip)) end private def message(ip)
  1. Similar code found in 2 nodes Locations: 0 1
  2. NotifyTrendingIpJob#message has approx 7 statements
params = [] params << ip.count
  1. NotifyTrendingIpJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << start_time(ip)
  1. NotifyTrendingIpJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << end_time(ip)
  1. NotifyTrendingIpJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << petition_link(ip)
  1. NotifyTrendingIpJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << ip_address_link(ip)
  1. NotifyTrendingIpJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
"%d signatures between %s and %s on %s from %s" % params end def rate_limit @rate_limit ||= RateLimit.first_or_create! end def slack @slack ||= Slack::Notifier.new(trending_items_notification_url) end def time_format "%-I:%M%P" end def start_time(ip) ip.starts_at.strftime(time_format) end def end_time(ip) ip.ends_at.strftime(time_format) end def petition_link(ip) "<#{admin_petition_url(ip.petition)}|#{ip.petition.action}>"
  1. NotifyTrendingIpJob#petition_link calls 'ip.petition' 2 times
  2. NotifyTrendingIpJob#petition_link refers to 'ip' more than self (maybe move it to another class?)
end def ip_address_link(ip) "<#{admin_petition_signatures_url(ip.petition, q: ip.ip_address, window: ip.window)}|#{ip.ip_address}>"
  1. NotifyTrendingIpJob#ip_address_link calls 'ip.ip_address' 2 times
  2. NotifyTrendingIpJob#ip_address_link refers to 'ip' more than self (maybe move it to another class?)
end end