citrusbyte/ripple

View on GitHub
lib/ripple/associations.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Association has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Association
    include Ripple::Translation
    attr_reader :type, :name, :options

    # association options :using, :class_name, :class, :extend, :foreign_key, :inverse
Severity: Minor
Found in lib/ripple/associations.rb - About 2 hrs to fix

    File associations.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'active_support/concern'
    require 'active_support/dependencies'
    require 'riak/walk_spec'
    require 'ripple/translation'
    require 'ripple/associations/proxy'
    Severity: Minor
    Found in lib/ripple/associations.rb - About 2 hrs to fix

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

          def validate!(owner)
            # TODO: Refactor this into an association subclass. See also GH #284
            if @options[:using] == :stored_key || @options.has_key?(:foreign_key)
              @options[:using] = :stored_key # Ensure Proxy class
              unless prop_name = @options[:foreign_key]
      Severity: Minor
      Found in lib/ripple/associations.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 propagate_callbacks_to_embedded_associations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def propagate_callbacks_to_embedded_associations(name, kind)
            self.class.embedded_associations.each do |association|
              documents = instance_variable_get(association.ivar)
              # We must explicitly check #nil? (rather than just saying `if documents`)
              # because documents can be an association proxy that is proxying nil.
      Severity: Minor
      Found in lib/ripple/associations.rb - About 55 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 define_callbacks_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def define_callbacks_on(klass)
            _association = self
      
            klass.before_save do
              if _association.linked? && !@_in_save_loaded_documents_callback
      Severity: Minor
      Found in lib/ripple/associations.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 attributes_for_persistence has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def attributes_for_persistence
            self.class.embedded_associations.inject(super) do |attrs, association|
              documents = instance_variable_get(association.ivar)
              # We must explicitly check #nil? (rather than just saying `if documents`)
              # because documents can be an association proxy that is proxying nil.
      Severity: Minor
      Found in lib/ripple/associations.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

      Method type_matches? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def type_matches?(value)
            case
            when polymorphic?
              one? || value.is_a?(Array)
            when many?
      Severity: Minor
      Found in lib/ripple/associations.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