zammad/zammad

View on GitHub
app/models/cti/log.rb

Summary

Maintainability
D
2 days
Test Coverage

File log.rb has 492 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Cti
  class Log < ApplicationModel
    include HasSearchIndexBackend

    self.table_name = 'cti_logs'
Severity: Minor
Found in app/models/cti/log.rb - About 7 hrs to fix

    Method process has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.process(params)
          cause   = params['cause']
          event   = params['event']
          user    = params['user']
          queue   = params['queue']
    Severity: Minor
    Found in app/models/cti/log.rb - About 5 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 process has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.process(params)
          cause   = params['cause']
          event   = params['event']
          user    = params['user']
          queue   = params['queue']
    Severity: Major
    Found in app/models/cti/log.rb - About 3 hrs to fix

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

          def best_customer_id_of_log_entry
            customer_id = nil
            if preferences[:from].present?
              preferences[:from].each do |entry|
                if customer_id.blank?
      Severity: Minor
      Found in app/models/cti/log.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 queues_of_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.queues_of_user(user, config)
            queues = []
            config[:notify_map]&.each do |row|
              next if row[:user_ids].blank?
              next if row[:user_ids].exclude?(user.id.to_s) && row[:user_ids].exclude?(user.id)
      Severity: Minor
      Found in app/models/cti/log.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

      There are no issues that match your filters.

      Category
      Status