zammad/zammad

View on GitHub
lib/models.rb

Summary

Maintainability
D
1 day
Test Coverage

Method references has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

  def self.references(object_name, object_id, include_zero = false)
    object_name = object_name.to_s

    # check if model exists
    object_name.constantize.find(object_id)
Severity: Minor
Found in lib/models.rb - About 1 day 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 references has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.references(object_name, object_id, include_zero = false)
    object_name = object_name.to_s

    # check if model exists
    object_name.constantize.find(object_id)
Severity: Major
Found in lib/models.rb - About 2 hrs to fix

    Method all has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.all
        @all ||= begin
          all    = {}
          dir    = Rails.root.join('app/models').to_s
          tables = ActiveRecord::Base.connection.tables
    Severity: Minor
    Found in lib/models.rb - About 1 hr to fix

      Method merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.merge(object_name, object_id_primary, object_id_to_merge, force = false)
      
          # if lower x references to update, do it right now
          if force
            total = references_total(object_name, object_id_to_merge)
      Severity: Minor
      Found in lib/models.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