zammad/zammad

View on GitHub
app/models/cti/driver/base.rb

Summary

Maintainability
D
1 day
Test Coverage

Method push_incoming_call has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def push_incoming_call(log)
    return if log.destroyed?
    return if @params[:event] != 'newCall'
    return if @params[:direction] != 'in'

Severity: Minor
Found in app/models/cti/driver/base.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 push_incoming_call has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def push_incoming_call(log)
    return if log.destroyed?
    return if @params[:event] != 'newCall'
    return if @params[:direction] != 'in'

Severity: Minor
Found in app/models/cti/driver/base.rb - About 1 hr to fix

    Method push_open_ticket_screen has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def push_open_ticket_screen(log)
        return if log.destroyed?
        return if @params[:event] != 'answer'
        return if @params[:direction] != 'in'
    
    
    Severity: Minor
    Found in app/models/cti/driver/base.rb - About 1 hr to fix

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

        def caller_id_rewrite(params)
          return nil if params['direction'] != 'out'
          return nil if params['event'] != 'newCall'
      
          config_outbound = @config[:outbound]
      Severity: Minor
      Found in app/models/cti/driver/base.rb - About 1 hr to fix

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

          def caller_id_rewrite(params)
            return nil if params['direction'] != 'out'
            return nil if params['event'] != 'newCall'
        
            config_outbound = @config[:outbound]
        Severity: Minor
        Found in app/models/cti/driver/base.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 push_open_ticket_screen has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def push_open_ticket_screen(log)
            return if log.destroyed?
            return if @params[:event] != 'answer'
            return if @params[:direction] != 'in'
        
        
        Severity: Minor
        Found in app/models/cti/driver/base.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def process
        
            # validate directions
            result = direction_check
            return result if result.present?
        Severity: Minor
        Found in app/models/cti/driver/base.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

        Avoid too many return statements within this method.
        Open

            return if !user.permissions?('cti.agent')
        Severity: Major
        Found in app/models/cti/driver/base.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return
          Severity: Major
          Found in app/models/cti/driver/base.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return {
                    action: 'set_caller_id',
                    params: {
                      from_caller_id: default_caller_id,
                      to_caller_id:   params[:to],
            Severity: Major
            Found in app/models/cti/driver/base.rb - About 30 mins to fix

              Method push_open_ticket_screen_recipient has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def push_open_ticket_screen_recipient
              
                  # try to find answering which answered call
                  user = nil
              
              
              Severity: Minor
              Found in app/models/cti/driver/base.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 reject_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def reject_check
                  return nil if @params['direction'] != 'in'
                  return nil if @params['event'] != 'newCall'
              
                  config_inbound = @config[:inbound] || {}
              Severity: Minor
              Found in app/models/cti/driver/base.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

              There are no issues that match your filters.

              Category
              Status