Conversation
has 32 functions (exceeds 20 allowed). Consider refactoring.
Zest.Telephony.Models.Conversation = Backbone.Model.extend({
urlRoot: Zest.Telephony.Config.CONVERSATION_PATH,
defaults: {
state: "disabled_by_default"
ConversationView
has 31 functions (exceeds 20 allowed). Consider refactoring.
Zest.Telephony.Views.ConversationView = Backbone.View.extend({
className: 'conversation-wrapper',
events: {
'click button.initiate-conversation' : 'createConversation',
Class Conversation
has 30 methods (exceeds 20 allowed). Consider refactoring.
class Conversation < Base
extend Telephony::NumberHelper
include ConversationStateMachine
module CONVERSATION_TYPES
Function Push
has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Zest.Telephony.Push = (function($) {
return {
init: function(socket) {
this.lastCallEventId = 0;
this.lastQueueChangeEventId = 0;
Method check_for_terminate
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
def check_for_terminate
if active_on_call.size == 0
terminate!
elsif one_step_transferring? && active_on_call.size == 1
fail_one_step_transfer!
File conversation_view.js
has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Zest.Telephony.Views.ConversationView = Backbone.View.extend({
className: 'conversation-wrapper',
events: {
'click button.initiate-conversation' : 'createConversation',
Method child_detached
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def child_detached
@child_call = @call.conversation.child_call(params[:DialCallSid])
@child_call.record! params
@child_call.sid ||= params[:DialCallSid]
Function init
has 40 lines of code (exceeds 25 allowed). Consider refactoring.
init: function(socket) {
this.lastCallEventId = 0;
this.lastQueueChangeEventId = 0;
this.lastStatusChangeEventAt = 0;
var $widgetWrapper = $("#telephony-widget");
Function Application
has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Zest.Telephony.Application = (function () {
var instance;
return {
init: function(agent) {
Method child_detached
has 36 lines of code (exceeds 25 allowed). Consider refactoring.
def child_detached
@child_call = @call.conversation.child_call(params[:DialCallSid])
@child_call.record! params
@child_call.sid ||= params[:DialCallSid]
Method search
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
def self.search(args = {})
conversations = Conversation.scoped
.includes(:events, calls: [:recordings, :voicemail])
.order("telephony_conversations.created_at")
.reverse_order
Method terminate_conversation_and_all_call_legs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def terminate_conversation_and_all_call_legs(trace_only = false)
if self.conversation
Rails.logger.info "zestphone: ** Terminating all linked calls and conversation **"
Method verify_status!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def verify_status!
return unless on_a_call?
call = active_call
if call.nil?
Method search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def self.search(args = {})
conversations = Conversation.scoped
.includes(:events, calls: [:recordings, :voicemail])
.order("telephony_conversations.created_at")
.reverse_order
Method two_step_transfer!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def two_step_transfer!(agent)
unless agent.transferrable?
errors[:base] << 'Agent is unavailable'
return false
end
Method dequeue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def self.dequeue(csr_id)
with_agent_on_a_call(csr_id) do |agent|
begin
conversation = oldest_queued_conversation
Method transfer!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def transfer!(csr_id, one_step)
unless in_progress? || in_progress_hold?
errors[:base] << "Conversation already #{state}"
return false
end
Method after_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def after_save(call)
return unless call.agent_id
Agent.find_with_lock(call.agent_id) do |agent|
if call.terminated? && call.state_was != 'not_initiated' && call.state_was != 'terminated'
Method authenticate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def authenticate
@agent = Agent.find_by_csr_id params[:csr_id]
@agent.verify_status!