activerecord/lib/active_record/associations/join_dependency.rb

Summary

Maintainability
C
1 day
Test Coverage

Method construct has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        def construct(ar_parent, parent, row, seen, model_cache, strict_loading_value)
          return if ar_parent.nil?

          parent.children.each do |node|
            if node.reflection.collection?
Severity: Minor
Found in activerecord/lib/active_record/associations/join_dependency.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 make_constraints has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def make_constraints(parent, child, join_type)
          foreign_table = parent.table
          foreign_klass = parent.base_klass
          child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker) do |reflection|
            table, terminated = @joined_tables[reflection]
Severity: Minor
Found in activerecord/lib/active_record/associations/join_dependency.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 instantiate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def instantiate(result_set, strict_loading_value, &block)
        primary_key = aliases.column_alias(join_root, join_root.primary_key)

        seen = Hash.new { |i, parent|
          i[parent] = Hash.new { |j, child_class|
Severity: Minor
Found in activerecord/lib/active_record/associations/join_dependency.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 instantiate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def instantiate(result_set, strict_loading_value, &block)
        primary_key = aliases.column_alias(join_root, join_root.primary_key)

        seen = Hash.new { |i, parent|
          i[parent] = Hash.new { |j, child_class|
Severity: Minor
Found in activerecord/lib/active_record/associations/join_dependency.rb - About 1 hr to fix

    Method construct_model has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def construct_model(record, node, row, model_cache, id, strict_loading_value)
              other = record.association(node.reflection.name)
    
              unless model = model_cache[node][id]
                model = node.instantiate(row, aliases.column_aliases(node)) do |m|
    Severity: Minor
    Found in activerecord/lib/active_record/associations/join_dependency.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 construct has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def construct(ar_parent, parent, row, seen, model_cache, strict_loading_value)
              return if ar_parent.nil?
    
              parent.children.each do |node|
                if node.reflection.collection?
    Severity: Minor
    Found in activerecord/lib/active_record/associations/join_dependency.rb - About 1 hr to fix

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

            def join_constraints(joins_to_add, alias_tracker, references)
              @alias_tracker = alias_tracker
              @joined_tables = {}
              @references = {}
      
      
      Severity: Minor
      Found in activerecord/lib/active_record/associations/join_dependency.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 construct_model has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def construct_model(record, node, row, model_cache, id, strict_loading_value)
      Severity: Minor
      Found in activerecord/lib/active_record/associations/join_dependency.rb - About 45 mins to fix

        Method construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def construct(ar_parent, parent, row, seen, model_cache, strict_loading_value)
        Severity: Minor
        Found in activerecord/lib/active_record/associations/join_dependency.rb - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status