PerfectlyNormal/mm-nested-attributes

View on GitHub

Showing 4 of 4 total issues

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

          def remove_embedded_associated_records
            associations.each do |key, association|
              next unless association.embeddable?

              if association.many?
Severity: Minor
Found in lib/mongo_mapper/plugins/associations/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_one_to_one_association has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        def assign_nested_attributes_for_one_to_one_association(association_name, attributes_collection)
          #require 'ruby_debug';debugger
          options = nested_attributes_options[association_name]
          association = associations[association_name]
          record = send(association_name)
Severity: Minor
Found in lib/mongo_mapper/plugins/associations/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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
          options = nested_attributes_options[association_name]

          unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array)
            raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
Severity: Minor
Found in lib/mongo_mapper/plugins/associations/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 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 lib/mongo_mapper/plugins/associations/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

Severity
Category
Status
Source
Language