activerecord/lib/active_record/nested_attributes.rb

Summary

Maintainability
C
1 day
Test Coverage

Method assign_nested_attributes_for_collection_association has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

      def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
        options = nested_attributes_options[association_name]
        if attributes_collection.respond_to?(:permitted?)
          attributes_collection = attributes_collection.to_h
        end
Severity: Minor
Found in activerecord/lib/active_record/nested_attributes.rb - About 4 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 assign_nested_attributes_for_one_to_one_association has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def assign_nested_attributes_for_one_to_one_association(association_name, attributes)
        if attributes.respond_to?(:permitted?)
          attributes = attributes.to_h
        end

Severity: Minor
Found in activerecord/lib/active_record/nested_attributes.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 assign_nested_attributes_for_collection_association has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
        options = nested_attributes_options[association_name]
        if attributes_collection.respond_to?(:permitted?)
          attributes_collection = attributes_collection.to_h
        end
Severity: Minor
Found in activerecord/lib/active_record/nested_attributes.rb - About 1 hr to fix

    Method assign_nested_attributes_for_one_to_one_association has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def assign_nested_attributes_for_one_to_one_association(association_name, attributes)
            if attributes.respond_to?(:permitted?)
              attributes = attributes.to_h
            end
    
    
    Severity: Minor
    Found in activerecord/lib/active_record/nested_attributes.rb - About 1 hr to fix

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

            def accepts_nested_attributes_for(*attr_names)
              options = { allow_destroy: false, update_only: false }
              options.update(attr_names.extract_options!)
              options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only)
              options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank
      Severity: Minor
      Found in activerecord/lib/active_record/nested_attributes.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 check_record_limit! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_record_limit!(limit, attributes_collection)
              if limit
                limit = \
                  case limit
                  when Symbol
      Severity: Minor
      Found in activerecord/lib/active_record/nested_attributes.rb - About 25 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