mongodb/mongo-ruby-driver

View on GitHub

Showing 312 of 370 total issues

Method verify_one_responder has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def verify_one_responder(uri)
        original_uri = uri
        redirect_count = 0
        http_response = nil
        loop do
Severity: Major
Found in lib/mongo/socket/ocsp_verifier.rb - About 4 hrs to fix

    Class Collection has 34 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 View has 34 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

        File options_mapper.rb has 334 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Mongo
          class URI
        
            # Performs mapping between URI options and Ruby options.
            #
        Severity: Minor
        Found in lib/mongo/uri/options_mapper.rb - About 4 hrs to fix

          Method check_out has 99 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def check_out
                  check_invariants
          
                  publish_cmap_event(
                    Monitoring::Event::Cmap::ConnectionCheckOutStarted.new(@server.address)
          Severity: Major
          Found in lib/mongo/server/connection_pool.rb - About 3 hrs to fix

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

                def server_description_changed
                  @previous_server_descriptions = servers_list.map do |server|
                    [server.address.to_s, server.description]
                  end
            
            
            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 Cluster has 31 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

              Class Binding has 30 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class Binding
                    extend FFI::Library
              
                    begin
                      ffi_lib ENV['LIBMONGOCRYPT_PATH']
              Severity: Minor
              Found in lib/mongo/crypt/binding.rb - About 3 hrs to fix

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

                    def parse!(remaining)
                      hosts_and_db, options = remaining.split('?', 2)
                      if options && options.index('?')
                        raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
                      end
                Severity: Minor
                Found in lib/mongo/uri.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 validate_new_options! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_new_options!(opts = Options::Redacted.new)
                      return Options::Redacted.new unless opts
                      if opts[:read_concern]
                        # Raise an error for non user-settable options
                        if opts[:read_concern][:after_cluster_time]
                Severity: Minor
                Found in lib/mongo/client.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 initialize has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize(seeds, monitoring, options = Options::Redacted.new)
                      if seeds.nil?
                        raise ArgumentError, 'Seeds cannot be nil'
                      end
                
                
                Severity: Major
                Found in lib/mongo/cluster.rb - About 3 hrs to fix

                  Method select_server has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def select_server(cluster, ping = nil, session = nil)
                          server_selection_timeout = cluster.options[:server_selection_timeout] || SERVER_SELECTION_TIMEOUT
                  
                          # Special handling for zero timeout: if we have to select a server,
                          # and the timeout is zero, fail immediately (since server selection
                  Severity: Major
                  Found in lib/mongo/server_selector/base.rb - About 3 hrs to fix

                    File base.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module Mongo
                    
                      module ServerSelector
                    
                        class Base
                    Severity: Minor
                    Found in lib/mongo/server_selector/base.rb - About 3 hrs to fix

                      Method initialize has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def initialize(addresses_or_uri, options = nil)
                            options = options ? options.dup : {}
                      
                            srv_uri = nil
                            if addresses_or_uri.is_a?(::String)
                      Severity: Major
                      Found in lib/mongo/client.rb - About 3 hrs to fix

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

                          class Server
                            extend Forwardable
                            include Monitoring::Publishable
                            include Event::Publisher
                        
                        
                        Severity: Minor
                        Found in lib/mongo/server.rb - About 3 hrs to fix

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

                              def initialize(seeds, monitoring, options = Options::Redacted.new)
                                if seeds.nil?
                                  raise ArgumentError, 'Seeds cannot be nil'
                                end
                          
                          
                          Severity: Minor
                          Found in lib/mongo/cluster.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 with_transaction has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def with_transaction(options=nil)
                                # Non-configurable 120 second timeout for the entire operation
                                deadline = Time.now + 120
                                transaction_in_progress = false
                                loop do
                          Severity: Major
                          Found in lib/mongo/session.rb - About 3 hrs to fix

                            Class ScramConversationBase has 26 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                                class ScramConversationBase < SaslConversationBase
                            
                                  # The minimum iteration count for SCRAM-SHA-1 and SCRAM-SHA-256.
                                  MIN_ITER_COUNT = 4096
                            
                            
                            Severity: Minor
                            Found in lib/mongo/auth/scram_conversation_base.rb - About 3 hrs to fix

                              Method server_description_changed has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def server_description_changed
                                    @previous_server_descriptions = servers_list.map do |server|
                                      [server.address.to_s, server.description]
                                    end
                              
                              
                              Severity: Major
                              Found in lib/mongo/cluster/sdam_flow.rb - About 3 hrs to fix

                                Method initialize has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def initialize(addresses_or_uri, options = nil)
                                      options = options ? options.dup : {}
                                
                                      srv_uri = nil
                                      if addresses_or_uri.is_a?(::String)
                                Severity: Minor
                                Found in lib/mongo/client.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