zammad/zammad

View on GitHub
lib/sessions.rb

Summary

Maintainability
D
2 days
Test Coverage

Method jobs has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

  def self.jobs(node_id = nil)

    # dispatch sessions
    if node_id.blank? && ENV['ZAMMAD_SESSION_JOBS_CONCURRENT'].to_i.positive?

Severity: Minor
Found in lib/sessions.rb - About 6 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

File sessions.rb has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Sessions

  @store = case Rails.application.config.websocket_session_store
           when :redis then Sessions::Store::Redis.new
           else Sessions::Store::File.new
Severity: Minor
Found in lib/sessions.rb - About 4 hrs to fix

    Method jobs has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.jobs(node_id = nil)
    
        # dispatch sessions
        if node_id.blank? && ENV['ZAMMAD_SESSION_JOBS_CONCURRENT'].to_i.positive?
    
    
    Severity: Major
    Found in lib/sessions.rb - About 2 hrs to fix

      Method broadcast has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.broadcast(data, recipient = 'authenticated', sender_user_id = nil)
      
          # list all current clients
          recipients = []
          client_list = sessions
      Severity: Minor
      Found in lib/sessions.rb - About 2 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 send_to has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.send_to(user_id, data)
      
          # list all current clients
          client_list = sessions
          client_list.each do |client_id|
      Severity: Minor
      Found in lib/sessions.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 thread_client has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.thread_client(client_id, try_count = 0, try_run_time = Time.now.utc, node_id)
          log('debug', "LOOP #{node_id}.#{client_id} - #{try_count}")
          begin
            Sessions::Client.new(client_id, node_id)
          rescue => e
      Severity: Minor
      Found in lib/sessions.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