adhearsion/adhearsion

View on GitHub

Showing 81 of 81 total issues

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

        def connect_to_server
          logger.info "Starting connection to server"
          client.run
        rescue Adhearsion::Rayo::DisconnectedError => e
          # We only care about disconnects if the process is up or booting
Severity: Minor
Found in lib/adhearsion/rayo/initializer.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 split has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def split(targets = {})
          @splitting = true
          calls_to_split = @calls.map do |call|
            ignoring_ended_calls do
              [call.id, call] if call.active?
Severity: Minor
Found in lib/adhearsion/call_controller/dial.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 dial has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def dial(to, options = {})
      options = options.dup
      options[:to] = to
      if options[:timeout]
        wait_timeout = options[:timeout]
Severity: Minor
Found in lib/adhearsion/outbound_call.rb - About 1 hr to fix

    Method split has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def split(targets = {})
              @splitting = true
              calls_to_split = @calls.map do |call|
                ignoring_ended_calls do
                  [call.id, call] if call.active?
    Severity: Minor
    Found in lib/adhearsion/call_controller/dial.rb - About 1 hr to fix

      Method start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def start
            catch :boot_aborted do
              configure_plugins
              load_lib_folder
              load_app_file
      Severity: Minor
      Found in lib/adhearsion/initializer.rb - About 1 hr to fix

        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/adhearsion/translator/asterisk/component/record.rb - About 1 hr to fix

          Method dispatch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def dispatch(call, callback = nil)
                  Adhearsion::Events.trigger_immediately :call_routed, call: call, route: self
          
                  call_id = call.id # Grab this to use later incase the actor is dead
          
          
          Severity: Minor
          Found in lib/adhearsion/router/route.rb - About 1 hr to fix

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

                  def init(name = nil, opts = {}, &block)
                    name = plugin_name unless name
                    block_given? or raise ArgumentError, "A block must be passed while defining the Plugin initialization process"
                    opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
                    Adhearsion::Plugin.initializers << Initializer.new(name, self, opts, &block)
            Severity: Minor
            Found in lib/adhearsion/plugin.rb and 1 other location - About 1 hr to fix
            lib/adhearsion/plugin.rb on lines 224..228

            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 47.

            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

                  def run(name = nil, opts = {}, &block)
                    name = plugin_name unless name
                    block_given? or raise ArgumentError, "A block must be passed while defining the Plugin run process"
                    opts[:after] ||= runners.last.name unless runners.empty? || runners.find { |i| i.name == opts[:before] }
                    Adhearsion::Plugin.runners << Initializer.new(name, self, opts, &block)
            Severity: Minor
            Found in lib/adhearsion/plugin.rb and 1 other location - About 1 hr to fix
            lib/adhearsion/plugin.rb on lines 212..216

            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 47.

            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 execute_from_app_dir! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def execute_from_app_dir!(path)
                    if in_app? and running_script_ahn?
                      return Dir.pwd
                    end
            
            
            Severity: Minor
            Found in lib/adhearsion/cli_commands/ahn_command.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 description has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def description(name, args = {:show_values => true})
                  desc = StringIO.new
            
                  name.nil? and name = :core
                  if name.eql? :all
            Severity: Minor
            Found in lib/adhearsion/configuration.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 << 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/adhearsion/translator/asterisk/component/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 config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def config(name = nil, &block)
                    if name.nil?
                      name = self.plugin_name
                    else
                      self.plugin_name = name
            Severity: Minor
            Found in lib/adhearsion/plugin.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

            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/adhearsion/rayo/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

            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

              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/adhearsion/rayo/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/adhearsion/translator/asterisk/component/dtmf_recognizer.rb - About 35 mins to fix

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

                      def dial(to, options = {})
                        options = options.dup
                        options[:to] = to
                        if options[:timeout]
                          wait_timeout = options[:timeout]
                  Severity: Minor
                  Found in lib/adhearsion/outbound_call.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def init(name = nil, opts = {}, &block)
                          name = plugin_name unless name
                          block_given? or raise ArgumentError, "A block must be passed while defining the Plugin initialization process"
                          opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
                          Adhearsion::Plugin.initializers << Initializer.new(name, self, opts, &block)
                  Severity: Minor
                  Found in lib/adhearsion/plugin.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/adhearsion/rayo/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

                  Severity
                  Category
                  Status
                  Source
                  Language