adhearsion/adhearsion

View on GitHub
lib/adhearsion/translator/asterisk/call.rb

Summary

Maintainability
F
3 days
Test Coverage

Method process_ami_event has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
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

Severity: Minor
Found in lib/adhearsion/translator/asterisk/call.rb - About 5 hrs to fix

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

require 'has_guarded_handlers'
require 'adhearsion/translator/asterisk/ami_error_converter'

module Adhearsion
  module Translator
Severity: Minor
Found in lib/adhearsion/translator/asterisk/call.rb - About 4 hrs to fix

    Method execute_command has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in lib/adhearsion/translator/asterisk/call.rb - About 4 hrs to fix

    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

          class Call
            include HasGuardedHandlers
    
            InvalidCommandError = Class.new Error
    
    
    Severity: Minor
    Found in lib/adhearsion/translator/asterisk/call.rb - About 3 hrs to fix

      Method execute_command has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      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
      Severity: Major
      Found in lib/adhearsion/translator/asterisk/call.rb - About 3 hrs to fix

        Method process_ami_event has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        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
        
        
        Severity: Major
        Found in lib/adhearsion/translator/asterisk/call.rb - About 3 hrs to fix

          Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def initialize(channel, translator, ami_client, connection, agi_env = nil, id = nil)
          Severity: Minor
          Found in lib/adhearsion/translator/asterisk/call.rb - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status