mongoid/mongoid

View on GitHub
lib/mongoid/relations/referenced/many.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Many has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Many < Relations::Many

        delegate :count, to: :criteria
        delegate :first, :in_memory, :last, :reset, :uniq, to: :target

Severity: Minor
Found in lib/mongoid/relations/referenced/many.rb - About 5 hrs to fix

    File many.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Mongoid
      module Relations
        module Referenced
    
          # This class defines the behaviour for all relations that are a
    Severity: Minor
    Found in lib/mongoid/relations/referenced/many.rb - About 2 hrs to fix

      Method remove_not_in has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def remove_not_in(ids)
                removed = criteria.not_in(_id: ids)
                if __metadata.destructive?
                  removed.delete_all
                else
      Severity: Minor
      Found in lib/mongoid/relations/referenced/many.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 purge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def purge
                unless __metadata.destructive?
                  nullify
                else
                  after_remove_error = nil
      Severity: Minor
      Found in lib/mongoid/relations/referenced/many.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 concat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def concat(documents)
                docs, inserts = [], []
                documents.each do |doc|
                  next unless doc
                  append(doc)
      Severity: Minor
      Found in lib/mongoid/relations/referenced/many.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