adhearsion/adhearsion

View on GitHub

Showing 81 of 81 total issues

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

  class Initializer

    class << self
      def start(*args, &block)
        new(*args, &block).start
Severity: Minor
Found in lib/adhearsion/initializer.rb - About 2 hrs to fix

    Class Plugin has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Plugin
    
        METHODS_OPTIONS = {:load => true, :scope => false}
    
        class << self
    Severity: Minor
    Found in lib/adhearsion/plugin.rb - About 2 hrs to fix

      Class CallController has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class CallController
          module Output
            PlaybackError = Class.new Adhearsion::Error # Represents failure to play audio, such as when the sound file cannot be found
            NoDocError = Class.new Adhearsion::Error # Represents failure to provide documents to playback
      
      
      Severity: Minor
      Found in lib/adhearsion/call_controller/output.rb - About 2 hrs to fix

        Method prep_calls has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def prep_calls
                  @calls = Set.new
                  @targets.map do |target, specific_options|
                    new_call = OutboundCall.new
        
        
        Severity: Minor
        Found in lib/adhearsion/call_controller/dial.rb - About 1 hr to fix

          Method validate has a Cognitive Complexity of 15 (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/adhearsion/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 register_initial_handlers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def register_initial_handlers
                register_event_handler Adhearsion::Event::Offer do |offer|
                  @offer  = offer
                  @client = offer.client
                  @start_time = offer.timestamp.to_time
          Severity: Minor
          Found in lib/adhearsion/call.rb - About 1 hr to fix

            Method init has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def init
                      self.config = Adhearsion.config.core
            
                      username = self.config.username
                      if (self.config.type || :xmpp) == :xmpp
            Severity: Minor
            Found in lib/adhearsion/rayo/initializer.rb - About 1 hr to fix

              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/adhearsion/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 exec_script_ahn! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.exec_script_ahn!(args = ARGV)
                    cwd = Dir.pwd
                    return unless in_ahn_application? || in_ahn_application_subdirectory?
                    exec RUBY, SCRIPT_AHN, *args if in_ahn_application?
                    Dir.chdir("..") do
              Severity: Minor
              Found in lib/adhearsion/script_ahn_loader.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 t has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def t(key, options = {})
                      this_locale = options[:locale] || locale
                      options = {default: '', locale: locale}.merge(options)
                      prompt = ::I18n.t "#{key}.audio", options
                      text   = ::I18n.t "#{key}.text", options
              Severity: Minor
              Found in lib/adhearsion/call_controller/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 take has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def take(call = nil)
                    case call
                    when Call
                      interact_with_call call
                    when String
              Severity: Minor
              Found in lib/adhearsion/console.rb - About 1 hr to fix

                Method cleanup_calls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                        def cleanup_calls
                          calls_to_hangup = @calls.map do |call|
                            ignoring_ended_calls do
                              [call.id, call] if call.active?
                            end
                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 take has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def take(call = nil)
                      case call
                      when Call
                        interact_with_call call
                      when String
                Severity: Minor
                Found in lib/adhearsion/console.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/adhearsion/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 register_initial_handlers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def register_initial_handlers
                      register_event_handler Adhearsion::Event::Offer do |offer|
                        @offer  = offer
                        @client = offer.client
                        @start_time = offer.timestamp.to_time
                Severity: Minor
                Found in lib/adhearsion/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 description has 30 lines of code (exceeds 25 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 1 hr to fix

                  Method setup_event_handlers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.setup_event_handlers
                        Events.rayo(Adhearsion::Event::Offer) do
                          begin
                            Celluloid::Actor[:statistics].register_call_offered
                          ensure
                  Severity: Minor
                  Found in lib/adhearsion/statistics.rb - About 1 hr to fix

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

                        def write_and_await_response(command, timeout = 60, fatal = false)
                          @commands << command
                          write_command command
                    
                          error_handler = fatal ? ->(error) { raise error } : ->(error) { abort error }
                    Severity: Minor
                    Found in lib/adhearsion/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 10 (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/adhearsion/translator/asterisk/component/mrcp_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 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/adhearsion/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

                    Severity
                    Category
                    Status
                    Source
                    Language