adhearsion/punchblock

View on GitHub

Showing 54 of 54 total issues

Method execute_command has a Cognitive Complexity of 11 (exceeds 5 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 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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

          def validate
            raise OptionError, "The renderer #{renderer} is unsupported." unless renderer == 'asterisk'
            raise OptionError, "The recognizer #{recognizer} is unsupported." unless recognizer == 'unimrcp'

            raise OptionError, 'A document is required.' unless output_node.render_documents.count > 0
Severity: Minor
Found in lib/punchblock/translator/asterisk/component/mrcp_native_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 handle_ami_event has 29 lines of code (exceeds 25 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 1 hr to fix

    Method ami_dispatch_to_or_create_call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def ami_dispatch_to_or_create_call(event)
            calls_for_event = channels_for_ami_event(event).inject({}) do |h, channel|
              call = call_for_channel channel
              h[channel] = call if call
              h
    Severity: Minor
    Found in lib/punchblock/translator/asterisk.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 execute has 26 lines of code (exceeds 25 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 1 hr to fix

      Method << has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def <<(digit)
              cancel_initial_timer
              @buffer << digit unless terminating?(digit)
              case (match = get_match)
              when RubySpeech::GRXML::NoMatch
      Severity: Minor
      Found in lib/punchblock/translator/dtmf_recognizer.rb - About 55 mins 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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

                def validate
                  raise OptionError, "The renderer #{renderer} is unsupported." unless renderer == 'unimrcp'
                  raise OptionError, "The recognizer #{recognizer} is unsupported." unless recognizer == 'unimrcp'
                  raise OptionError, 'An SSML document is required.' unless output_node.render_documents.count > 0
                  raise OptionError, 'Only one document is allowed.' if output_node.render_documents.count > 1
      Severity: Minor
      Found in lib/punchblock/translator/asterisk/component/mrcp_prompt.rb - About 55 mins 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 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/punchblock/translator/asterisk/call.rb - About 45 mins to fix

        Method ping_rayo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def ping_rayo
                client.write_with_handler Blather::Stanza::Iq::Ping.new(:get, root_domain) do |response|
                  begin
                    handle_error response if response.is_a? Blather::BlatherError
                  rescue ProtocolError => e
        Severity: Minor
        Found in lib/punchblock/connection/xmpp.rb - About 45 mins 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                  register_handler :es, :event_name => 'CHANNEL_UNBRIDGE' do |event|
                    command = @pending_unjoins[event[:other_leg_unique_id]]
                    command.response = true if command
        
                    other_call_uri = event[:unique_id] == id ? event[:other_leg_unique_id] : event[:unique_id]
        Severity: Minor
        Found in lib/punchblock/translator/freeswitch/call.rb and 1 other location - About 45 mins to fix
        lib/punchblock/translator/freeswitch/call.rb on lines 91..96

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                   when 'BridgeLeave'
                    if other_call = ami_event['OtherCall']
                      event = Event::Unjoined.new call_uri: other_call.id, timestamp: ami_event.best_time
                      send_pb_event event
        
        
        Severity: Minor
        Found in lib/punchblock/translator/asterisk/call.rb and 1 other location - About 45 mins to fix
        lib/punchblock/translator/asterisk/call.rb on lines 139..146

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                  register_handler :es, :event_name => 'CHANNEL_BRIDGE' do |event|
                    command = @pending_joins[event[:other_leg_unique_id]]
                    command.response = true if command
        
                    other_call_uri = event[:unique_id] == id ? event[:other_leg_unique_id] : event[:unique_id]
        Severity: Minor
        Found in lib/punchblock/translator/freeswitch/call.rb and 1 other location - About 45 mins to fix
        lib/punchblock/translator/freeswitch/call.rb on lines 99..104

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                  when 'BridgeEnter'
                    if other_call = ami_event['OtherCall']
                      event = Event::Joined.new call_uri: other_call.id, timestamp: ami_event.best_time
                      send_pb_event event
        
        
        Severity: Minor
        Found in lib/punchblock/translator/asterisk/call.rb and 1 other location - About 45 mins to fix
        lib/punchblock/translator/asterisk/call.rb on lines 148..155

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method from_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.from_xml(node, call_id = nil, component_id = nil, uri = nil, timestamp = nil)
        Severity: Minor
        Found in lib/punchblock/rayo_node.rb - About 35 mins to fix

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

                def initialize(responder, grammar, initial_timeout = nil, inter_digit_timeout = nil, terminator = nil)
          Severity: Minor
          Found in lib/punchblock/translator/dtmf_recognizer.rb - About 35 mins to fix

            Method complete_event= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def complete_event=(other)
                    @mutex.synchronize do
                      return if @complete_event_resource.set_yet?
                      client.delete_component_registration self if client
                      complete!
            Severity: Minor
            Found in lib/punchblock/component/component_node.rb - About 35 mins 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(options = {})
                    raise ArgumentError unless (@username = options[:username]) && options[:password]
            
                    setup(*[:username, :password, :host, :port, :certs, :connection_timeout].map { |key| options.delete key })
            
            
            Severity: Minor
            Found in lib/punchblock/connection/xmpp.rb - About 35 mins 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 from_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.from_xml(node, call_id = nil, component_id = nil, uri = nil, timestamp = nil)
                  ns = (node.namespace.href if node.namespace)
                  klass = class_from_registration(node.name, ns)
                  if klass && klass != self
                    klass.from_xml node, call_id, component_id
            Severity: Minor
            Found in lib/punchblock/rayo_node.rb - About 35 mins 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 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def execute
                        validate
                        output_command.request!
                        setup_dtmf_recognizer
            
            
            Severity: Minor
            Found in lib/punchblock/translator/asterisk/component/composed_prompt.rb - About 25 mins 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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def validate
                    raise OptionError, 'A grammar document is required.' unless input_node.grammars.first
                    raise OptionError, 'Only a single grammar is supported.' unless input_node.grammars.size == 1
                    raise OptionError, 'A mode value other than DTMF is unsupported.' unless input_node.mode == :dtmf
                  end
            Severity: Minor
            Found in lib/punchblock/translator/input_component.rb - About 25 mins 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

            Severity
            Category
            Status
            Source
            Language