mongoid/mongoid

View on GitHub

Showing 92 of 92 total issues

Class Metadata has 81 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Metadata < Hash

      delegate :foreign_key_default, :stores_foreign_key?, to: :relation

      # Returns the as option of the relation.
Severity: Major
Found in lib/mongoid/relations/metadata.rb - About 1 day to fix

    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

      Method autosave has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

              def autosave(metadata)
                if metadata.autosave? && !metadata.embedded?
                  save_method = :"autosave_documents_for_#{metadata.name}"
                  define_method(save_method) do
      
      
      Severity: Minor
      Found in lib/mongoid/relations/auto_save.rb - About 5 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

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

            class Many < Relations::Many
              include Batchable
      
              # Appends a document or array of documents to the relation. Will set
              # the parent and update the index in the process.
      Severity: Minor
      Found in lib/mongoid/relations/embedded/many.rb - About 5 hrs to fix

        Class Mongo has 36 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Mongo
              include Enumerable
              include Aggregable::Mongo
              include Atomic
              include Relations::Eager
        Severity: Minor
        Found in lib/mongoid/contextual/mongo.rb - About 4 hrs to fix

          Class Criteria has 36 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Criteria
              include Enumerable
              include Contextual
              include Origin::Queryable
              include Findable
          Severity: Minor
          Found in lib/mongoid/criteria.rb - About 4 hrs to fix

            File metadata.rb has 338 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Mongoid
              module Relations
            
                # The "Grand Poobah" of information about any relation is this class. It
                # contains everything you could ever possible want to know.
            Severity: Minor
            Found in lib/mongoid/relations/metadata.rb - About 4 hrs to fix

              File profile.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require "perftools"
              require "mongoid"
              require "./perf/models"
              
              Mongoid.connect_to("mongoid_perf_test")
              Severity: Minor
              Found in perf/profile.rb - About 3 hrs to fix

                Class Enumerable has 27 methods (exceeds 20 allowed). Consider refactoring.
                Open

                      class Enumerable
                        include ::Enumerable
                
                        # The three main instance variables are collections of documents.
                        #
                Severity: Minor
                Found in lib/mongoid/relations/targets/enumerable.rb - About 3 hrs to fix

                  Class Memory has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Memory
                        include Enumerable
                        include Aggregable::Memory
                        include Relations::Eager
                        include Queryable
                  Severity: Minor
                  Found in lib/mongoid/contextual/memory.rb - About 3 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

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

                            class ManyToMany < Many
                      
                              # Appends a document or array of documents to the relation. Will set
                              # the parent and update the index in the process.
                              #
                      Severity: Minor
                      Found in lib/mongoid/relations/referenced/many_to_many.rb - About 2 hrs to fix

                        File benchmark.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        require "benchmark"
                        require "mongoid"
                        require "./perf/models"
                        
                        Mongoid.connect_to("mongoid_perf_test")
                        Severity: Minor
                        Found in perf/benchmark.rb - About 2 hrs to fix

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

                              def cascadable_children(kind, children = Set.new)
                                embedded_relations.each_pair do |name, metadata|
                                  next unless metadata.cascading_callbacks?
                                  without_autobuild do
                                    delayed_pulls = delayed_atomic_pulls[name]
                          Severity: Minor
                          Found in lib/mongoid/interceptable.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 undefined_indexes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def undefined_indexes(models = ::Mongoid.models)
                                  undefined_by_model = {}
                          
                                  models.each do |model|
                                    unless model.embedded?
                          Severity: Minor
                          Found in lib/mongoid/tasks/database.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

                          Class Modifiers has 22 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                              class Modifiers < Hash
                          
                                # Add the atomic $addToSet modifiers to the hash.
                                #
                                # @example Add the $addToSet modifiers.
                          Severity: Minor
                          Found in lib/mongoid/atomic/modifiers.rb - About 2 hrs to fix

                            File fields.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require "mongoid/fields/standard"
                            require "mongoid/fields/foreign_key"
                            require "mongoid/fields/localized"
                            require "mongoid/fields/validators"
                            
                            
                            Severity: Minor
                            Found in lib/mongoid/fields.rb - About 2 hrs to fix

                              Method add_counter_cache_callbacks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def add_counter_cache_callbacks(meta)
                                        name = meta.name
                                        cache_column = meta.counter_cache_column_name.to_sym
                              
                                        after_create do
                              Severity: Minor
                              Found in lib/mongoid/relations/counter_cache.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 substitute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def substitute(replacement)
                                        if replacement != self
                                          if _assigning?
                                            base.add_atomic_unset(target) unless replacement
                                          else
                              Severity: Minor
                              Found in lib/mongoid/relations/embedded/one.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 pre_process_batch_insert has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def pre_process_batch_insert(docs)
                                        docs.map do |doc|
                                          next unless doc
                                          append(doc)
                                          if persistable? && !_assigning?
                              Severity: Minor
                              Found in lib/mongoid/relations/embedded/batchable.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

                              Severity
                              Category
                              Status
                              Source
                              Language