adhearsion/punchblock

View on GitHub

Showing 40 of 54 total issues

Method unimrcp_app_options has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

          def unimrcp_app_options
            {uer: 1, b: (@component_node.barge_in == false ? 0 : 1)}.tap do |opts|
              opts[:nit] = @initial_timeout if @initial_timeout > -1
              opts[:dit] = @inter_digit_timeout if @inter_digit_timeout > -1
              opts[:dttc] = input_node.terminator if input_node.terminator
Severity: Minor
Found in lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb - About 1 day 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

Method execute_command has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

        def execute_command(command)
          if @block_commands
            command.response = ProtocolError.new.setup :item_not_found, "Could not find a call with ID #{id}", id
            return
          end
Severity: Minor
Found in lib/punchblock/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

File call.rb has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'punchblock/translator/asterisk/ami_error_converter'

module Punchblock
  module Translator
    class Asterisk
Severity: Minor
Found in lib/punchblock/translator/asterisk/call.rb - About 4 hrs to fix

    Method execute has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

              def execute
                raise OptionError, 'An SSML document is required.' unless @component_node.render_documents.first.value
                raise OptionError, 'An interrupt-on value of speech is unsupported.' if @component_node.interrupt_on == :voice
    
                [:start_offset, :start_paused, :repeat_interval, :max_time].each do |opt|
    Severity: Minor
    Found in lib/punchblock/translator/asterisk/component/output.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
            include DeadActorSafety
    
            InvalidCommandError = Class.new Punchblock::Error
    Severity: Minor
    Found in lib/punchblock/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 = ProtocolError.new.setup :item_not_found, "Could not find a call with ID #{id}", id
                  return
                end
      Severity: Major
      Found in lib/punchblock/translator/asterisk/call.rb - About 3 hrs to fix

        Method process_ami_event has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

                def process_ami_event(ami_event)
                  if Asterisk.event_passes_filter?(ami_event)
                    send_pb_event Event::Asterisk::AMI::Event.new(name: ami_event.name, headers: ami_event.headers)
                  end
        
        
        Severity: Minor
        Found in lib/punchblock/translator/asterisk/call.rb - About 3 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

        Method handle_ami_event has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

              def handle_ami_event(event)
                return unless event.is_a? RubyAMI::Event
        
                case event.name
                when 'FullyBooted'
        Severity: Minor
        Found in lib/punchblock/translator/asterisk.rb - About 3 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 Asterisk has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Asterisk
              include Celluloid
        
              # Indicates that a command was executed against a channel which no longer exists
              ChannelGoneError = Class.new Punchblock::Error
        Severity: Minor
        Found in lib/punchblock/translator/asterisk.rb - About 3 hrs to fix

          Method execute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                    def execute
                      max_duration = @component_node.max_duration || -1
          
                      raise OptionError, 'Record cannot be used on a call that is not answered.' unless @call.answered?
                      raise OptionError, 'A start-paused value of true is unsupported.' if @component_node.start_paused
          Severity: Minor
          Found in lib/punchblock/translator/asterisk/component/record.rb - About 2 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

          Method execute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                    def execute
                      max_duration = @component_node.max_duration || -1
                      initial_timeout = @component_node.initial_timeout || -1
                      final_timeout = @component_node.final_timeout || -1
          
          
          Severity: Minor
          Found in lib/punchblock/translator/freeswitch/component/record.rb - About 2 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 output.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Punchblock
            module Component
              class Output < ComponentNode
          
                include HasHeaders
          Severity: Minor
          Found in lib/punchblock/component/output.rb - About 2 hrs to fix

            Method process_ami_event has 69 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 Event::Asterisk::AMI::Event.new(name: ami_event.name, headers: ami_event.headers)
                      end
            
            
            Severity: Major
            Found in lib/punchblock/translator/asterisk/call.rb - About 2 hrs to fix

              Method setup_handlers has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                      def setup_handlers
                        register_handler :es, :event_name => 'CHANNEL_ANSWER' do
                          @answered = true
                          send_pb_event Event::Answered.new
                          throw :pass
              Severity: Minor
              Found in lib/punchblock/translator/freeswitch/call.rb - About 2 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

              Method execute has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        def execute
                          raise OptionError, 'An SSML document is required.' unless @component_node.render_documents.first.value
                          raise OptionError, 'An interrupt-on value of speech is unsupported.' if @component_node.interrupt_on == :voice
              
                          [:start_offset, :start_paused, :repeat_interval, :max_time].each do |opt|
              Severity: Major
              Found in lib/punchblock/translator/asterisk/component/output.rb - About 2 hrs to fix

                Class Call has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                      class Call
                        include HasGuardedHandlers
                        include Celluloid
                        include DeadActorSafety
                
                
                Severity: Minor
                Found in lib/punchblock/translator/freeswitch/call.rb - About 2 hrs to fix

                  Method execute_command has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def execute_command(command)
                            if command.component_id
                              if component = component_with_id(command.component_id)
                                component.execute_command command
                              else
                  Severity: Minor
                  Found in lib/punchblock/translator/freeswitch/call.rb - About 2 hrs to fix

                    Method validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def validate
                                [:interrupt_on, :start_offset, :start_paused, :repeat_interval, :repeat_times, :max_time].each do |opt|
                                  raise OptionError, "A #{opt} value is unsupported on Asterisk." if output_node.send opt
                                end
                    
                    
                    Severity: Minor
                    Found in lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb - About 1 hr 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

                    Method copied_doc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def copied_doc(original, elements)
                                doc = RubySpeech::SSML.draw do
                                  if Nokogiri.jruby?
                                    self.write_attr 'version', original.value['version']
                                    self.write_attr 'xml:lang', original.value['xml:lang']
                    Severity: Minor
                    Found in lib/punchblock/translator/asterisk/component/output.rb - About 1 hr 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

                    Method setup_handlers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def setup_handlers
                              register_handler :es, :event_name => 'CHANNEL_ANSWER' do
                                @answered = true
                                send_pb_event Event::Answered.new
                                throw :pass
                    Severity: Minor
                    Found in lib/punchblock/translator/freeswitch/call.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language