mongodb/mongo-ruby-driver

View on GitHub

Showing 144 of 187 total issues

File tables.rb has 3148 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Mongo
  module Auth
    module StringPrep
      # Contains character tables defined by RFC 3454 (string preparation).
      #
Severity: Major
Found in lib/mongo/auth/stringprep/tables.rb - About 1 wk to fix

    File tables.rb has 1161 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module UnicodeNormalize  # :nodoc:
      accents = "" \
        "[\u0300-\u034E\u0350-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7" \
        "\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711" \
        "\u0730-\u074A\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1" \
    Severity: Major
    Found in lib/mongo/auth/stringprep/unicode_normalize/tables.rb - About 2 days to fix

      Class URI has 55 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class URI
          include Loggable
      
          # The uri parser object options.
          #
      Severity: Major
      Found in lib/mongo/uri.rb - About 7 hrs to fix

        File uri.rb has 429 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'uri'
        
        module Mongo
        
          # The URI class provides a way for users to parse the MongoDB uri as
        Severity: Minor
        Found in lib/mongo/uri.rb - About 6 hrs to fix

          Class Session has 41 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Session
              extend Forwardable
              include Retryable
          
              # Get the options for this session.
          Severity: Minor
          Found in lib/mongo/session.rb - About 5 hrs to fix

            Class Description has 41 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class Description
            
                  # Constant for reading arbiter info from config.
                  #
                  # @since 2.0.0
            Severity: Minor
            Found in lib/mongo/server/description.rb - About 5 hrs to fix

              File session.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'mongo/session/session_pool'
              require 'mongo/session/server_session'
              
              module Mongo
              
              
              Severity: Minor
              Found in lib/mongo/session.rb - About 5 hrs to fix

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

                      class Conversation
                
                        # The base client continue message.
                        #
                        # @since 2.0.0
                Severity: Minor
                Found in lib/mongo/auth/scram/conversation.rb - About 4 hrs to fix

                  Method with_transaction has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def with_transaction(options=nil)
                        loop do
                          commit_options = {}
                          if options
                            commit_options[:write_concern] = options[:write_concern]
                  Severity: Minor
                  Found in lib/mongo/session.rb - About 4 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 View has 32 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class View
                  
                        # Defines read related behavior for collection view.
                        #
                        # @since 2.0.0
                  Severity: Minor
                  Found in lib/mongo/collection/view/readable.rb - About 4 hrs to fix

                    Class Collection has 32 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class Collection
                        extend Forwardable
                        include Retryable
                    
                        # The capped option.
                    Severity: Minor
                    Found in lib/mongo/collection.rb - About 4 hrs to fix

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

                        class Client
                          extend Forwardable
                          include Loggable
                      
                          # The options that do not affect the behavior of a cluster and its
                      Severity: Minor
                      Found in lib/mongo/client.rb - About 3 hrs to fix

                        File sdam_flow.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        class Mongo::Cluster
                          # Handles SDAM flow for a server description changed event.
                          #
                          # Updates server descriptions, topology descriptions and publishes
                          # SDAM events.
                        Severity: Minor
                        Found in lib/mongo/cluster/sdam_flow.rb - About 3 hrs to fix

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

                            class Cluster
                              extend Forwardable
                              include Monitoring::Publishable
                              include Event::Subscriber
                              include Loggable
                          Severity: Minor
                          Found in lib/mongo/cluster.rb - About 3 hrs to fix

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

                                  def handshake!
                                    unless socket && socket.connectable?
                                      raise Error::HandshakeError, "Cannot handshake because there is no usable socket"
                                    end
                            
                            
                            Severity: Minor
                            Found in lib/mongo/server/connection.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

                            Method server_description_changed has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def server_description_changed
                                  unless update_server_descriptions
                                    # All of the transitions require that server whose updated_desc we are
                                    # processing is still in the cluster (i.e., was not removed as a result
                                    # of processing another response, potentially concurrently).
                            Severity: Minor
                            Found in lib/mongo/cluster/sdam_flow.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 Cursor has 24 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                              class Cursor
                                extend Forwardable
                                include Enumerable
                                include Retryable
                            
                            
                            Severity: Minor
                            Found in lib/mongo/cursor.rb - About 2 hrs to fix

                              File cluster.rb has 276 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              require 'mongo/cluster/topology'
                              require 'mongo/cluster/reapers/socket_reaper'
                              require 'mongo/cluster/reapers/cursor_reaper'
                              require 'mongo/cluster/periodic_executor'
                              
                              
                              Severity: Minor
                              Found in lib/mongo/cluster.rb - About 2 hrs to fix

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

                                      def select_server(cluster, ping = nil)
                                        @local_threshold = cluster.options[:local_threshold] || LOCAL_THRESHOLD
                                        @server_selection_timeout = cluster.options[:server_selection_timeout] || SERVER_SELECTION_TIMEOUT
                                        deadline = Time.now + server_selection_timeout
                                        while (deadline - Time.now) > 0
                                Severity: Minor
                                Found in lib/mongo/server_selector/selectable.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 close_stale_sockets! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                Open

                                        def close_stale_sockets!
                                          check_count_invariants
                                          return unless max_idle_time
                                
                                          to_refresh = []
                                Severity: Minor
                                Found in lib/mongo/server/connection_pool/queue.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