akretion/ooor

View on GitHub
lib/ooor/autosave_association.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method save_collection_association has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def save_collection_association(reflection)
#        if association = association_instance_get(reflection.name)
        if target = @loaded_associations[reflection.name] #TODO use a real Association wrapper
          association = OpenStruct.new(target: target)
          autosave = reflection.options[:autosave]
Severity: Minor
Found in lib/ooor/autosave_association.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 add_autosave_association_callbacks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def add_autosave_association_callbacks(reflection) # TODO add support for m2o
          save_method = :"autosave_associated_records_for_#{reflection.name}"
          validation_method = :"validate_associated_records_for_#{reflection.name}"
          collection = true #reflection.collection?
          unless method_defined?(save_method)
Severity: Minor
Found in lib/ooor/autosave_association.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

There are no issues that match your filters.

Category
Status