mongodb/mongoid

View on GitHub

Showing 139 of 139 total issues

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

        def self.define_callbacks!(association)
          name = association.name
          cache_column = association.counter_cache_column_name.to_sym

          association.inverse_class.tap do |klass|
Severity: Minor
Found in lib/mongoid/association/referenced/counter_cache.rb - About 7 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 Mongo has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Mongo
      include Enumerable
      include Aggregable::Mongo
      include Atomic
      include Association::EagerLoadable
Severity: Minor
Found in lib/mongoid/contextual/mongo.rb - About 5 hrs to fix

    Class Proxy has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

            class Proxy < Association::Many
              include Batchable
    
              # Appends a document or array of documents to the association. Will set
              # the parent and update the index in the process.
    Severity: Minor
    Found in lib/mongoid/association/embedded/embeds_many/proxy.rb - About 4 hrs to fix

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

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

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

          class Criteria
            module Queryable
        
              # An queryable selectable is selectable, in that it has the ability to select
              # document from the database. The selectable module brings all functionality
        Severity: Minor
        Found in lib/mongoid/criteria/queryable/selectable.rb - About 3 hrs to fix

          Method set has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

                def set(setters)
                  prepare_atomic_operation do |ops|
                    process_atomic_operations(setters) do |field, value|
          
                      field_seq = field.to_s.split('.')
          Severity: Minor
          Found in lib/mongoid/persistable/settable.rb - About 3 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 Proxy has 29 methods (exceeds 20 allowed). Consider refactoring.
          Open

                  class Proxy < Association::Many
          
                    delegate :count, to: :criteria
                    delegate :first, :in_memory, :last, :reset, :uniq, to: :_target
          
          
          Severity: Minor
          Found in lib/mongoid/association/referenced/has_many/proxy.rb - About 3 hrs to fix

            Class Enumerable has 29 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/association/referenced/has_many/enumerable.rb - About 3 hrs to fix

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

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

                  File benchmark.rb has 285 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

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

                          class HasAndBelongsToMany
                            include Relatable
                            include Buildable
                    
                            # The options available for this type of association, in addition to the
                    Severity: Minor
                    Found in lib/mongoid/association/referenced/has_and_belongs_to_many.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, association|
                              next unless association.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

                      Class HasMany has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                            class HasMany
                              include Relatable
                              include Buildable
                      
                              # The options available for this type of association, in addition to the
                      Severity: Minor
                      Found in lib/mongoid/association/referenced/has_many.rb - About 2 hrs to fix

                        Class Modifiers has 23 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

                          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 Criteria has 22 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                            class Criteria
                              module Queryable
                          
                                # The optional module includes all behavior that has to do with extra
                                # options surrounding queries, like skip, limit, sorting, etc.
                          Severity: Minor
                          Found in lib/mongoid/criteria/queryable/optional.rb - About 2 hrs to fix

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

                            require "mongoid/contextual/atomic"
                            require "mongoid/contextual/aggregable/mongo"
                            require "mongoid/contextual/command"
                            require "mongoid/contextual/geo_near"
                            require "mongoid/contextual/map_reduce"
                            Severity: Minor
                            Found in lib/mongoid/contextual/mongo.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 atomically has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def atomically(join_context: nil)
                                      join_context = Mongoid.join_contexts if join_context.nil?
                                      call_depth = @atomic_depth ||= 0
                                      has_own_context = call_depth.zero? || !join_context
                                      @atomic_updates_to_execute_stack ||= []
                                Severity: Minor
                                Found in lib/mongoid/persistable.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

                                Severity
                                Category
                                Status
                                Source
                                Language