lib/adhearsion/translator/asterisk/call.rb
Method process_ami_event
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
Open
def process_ami_event(ami_event)
if Asterisk.event_passes_filter?(ami_event)
send_pb_event Adhearsion::Event::Asterisk::AMI.new(name: ami_event.name, headers: ami_event.headers)
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File call.rb
has 367 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'has_guarded_handlers'
require 'adhearsion/translator/asterisk/ami_error_converter'
module Adhearsion
module Translator
Method execute_command
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
Open
def execute_command(command)
if @block_commands
command.response = Adhearsion::ProtocolError.new.setup :item_not_found, "Could not find a call with ID #{id}", id
return
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class Call
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Call
include HasGuardedHandlers
InvalidCommandError = Class.new Error
Method execute_command
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def execute_command(command)
if @block_commands
command.response = Adhearsion::ProtocolError.new.setup :item_not_found, "Could not find a call with ID #{id}", id
return
end
Method process_ami_event
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def process_ami_event(ami_event)
if Asterisk.event_passes_filter?(ami_event)
send_pb_event Adhearsion::Event::Asterisk::AMI.new(name: ami_event.name, headers: ami_event.headers)
end
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def initialize(channel, translator, ami_client, connection, agi_env = nil, id = nil)