zammad/zammad

View on GitHub
app/models/channel.rb

Summary

Maintainability
D
1 day
Test Coverage

Method stream has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

  def self.stream
    Thread.abort_on_exception = true

    auto_reconnect_after = 180
    delay_before_reconnect = 70
Severity: Minor
Found in app/models/channel.rb - About 7 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 stream has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.stream
    Thread.abort_on_exception = true

    auto_reconnect_after = 180
    delay_before_reconnect = 70
Severity: Major
Found in app/models/channel.rb - About 3 hrs to fix

    File channel.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Channel < ApplicationModel
      include Channel::Assets
      include Channel::Area::Whatsapp
    
      belongs_to :group, optional: true
    Severity: Minor
    Found in app/models/channel.rb - About 2 hrs to fix

      Method refresh_xoauth2! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def refresh_xoauth2!(force: false)
          return if options.dig(:auth, :type) != 'XOAUTH2'
          return if !force && ApplicationHandleInfo.current == 'application_server'
      
          result = ExternalCredential.refresh_token(options[:auth][:provider], options[:auth])
      Severity: Minor
      Found in app/models/channel.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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def fetch(force = false)
          adapter         = options[:adapter]
          adapter_options = options
          if options[:inbound] && options[:inbound][:adapter]
            adapter         = options[:inbound][:adapter]
      Severity: Minor
      Found in app/models/channel.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

      There are no issues that match your filters.

      Category
      Status