mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

Method initialize has 87 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 change_doc has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

            def change_doc
              {}.tap do |doc|
                if @options[:full_document]
                  doc[:fullDocument] = @options[:full_document]
                end
    Severity: Minor
    Found in lib/mongo/collection/view/change_stream.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

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

    module Mongo
    
      # The URI class provides a way for users to parse the MongoDB uri as
      # defined in the connection string format spec.
      #
    Severity: Minor
    Found in lib/mongo/uri.rb - About 3 hrs to fix

      File writable.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Mongo
        class Collection
          class View
      
            # Defines write related behavior for collection view.
      Severity: Minor
      Found in lib/mongo/collection/view/writable.rb - About 3 hrs to fix

        Method server_description_changed has 80 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

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

              class Result
                extend Forwardable
                include Enumerable
          
                # The field name for the cursor document in an aggregation.
          Severity: Minor
          Found in lib/mongo/operation/result.rb - About 3 hrs to fix

            Method with_transaction has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Method parse! has a Cognitive Complexity of 22 (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 estimated_document_count has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                      def estimated_document_count(opts = {})
                        unless view.filter.empty?
                          raise ArgumentError, "Cannot call estimated_document_count when querying with a filter"
                        end
              
              
              Severity: Minor
              Found in lib/mongo/collection/view/readable.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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                    def initialize(options)
                      Crypt.validate_ffi!
                      # Note that this call may eventually, via other method invocations,
                      # create additional clients which have to be cleaned up.
                      @options = set_default_options(options).freeze
              Severity: Minor
              Found in lib/mongo/crypt/auto_encrypter.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

              File description.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Mongo
                class Server
              
                  # Represents a description of the server, populated by the result of the
                  # hello command.
              Severity: Minor
              Found in lib/mongo/server/description.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 commit_transaction has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def commit_transaction(options=nil)
                        QueryCache.clear
                        check_if_ended!
                        check_if_no_transaction!
                  
                  
                  Severity: Minor
                  Found in lib/mongo/session.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 validate_uri_options! has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def validate_uri_options!
                        # The URI options spec requires that we raise an error if there are conflicting values of
                        # 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
                        # array; assuming all values in the array are the same, we replace the array with that value.
                        unless uri_options[:ssl].nil? || uri_options[:ssl].empty?
                  Severity: Major
                  Found in lib/mongo/uri.rb - About 2 hrs to fix

                    Method read_from_socket has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def read_from_socket(length, timeout: nil)
                          # Just in case
                          if length == 0
                            return ''.force_encoding('BINARY')
                          end
                    Severity: Major
                    Found in lib/mongo/socket.rb - About 2 hrs to fix

                      Method run_sdam_flow has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def run_sdam_flow(previous_desc, updated_desc, options = {})
                            if load_balanced?
                              if updated_desc.config.empty?
                                unless options[:keep_connection_pool]
                                  servers_list.each do |server|
                      Severity: Minor
                      Found in lib/mongo/cluster.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 initial has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def initial(cluster, monitoring, options)
                              connect = options[:connect]&.to_sym
                              cls = if options[:direct_connection]
                                if connect && connect != :direct
                                  raise ArgumentError, "Conflicting topology options: direct_connection=true and connect=#{connect}"
                      Severity: Minor
                      Found in lib/mongo/cluster/topology.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 kill_cursors has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def kill_cursors
                              # TODO optimize this to batch kill cursor operations for the same
                              # server/database/collection instead of killing each cursor
                              # individually.
                              loop do
                      Severity: Minor
                      Found in lib/mongo/cluster/reapers/cursor_reaper.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 legacy_read_with_retry has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def legacy_read_with_retry(session, server_selector, &block)
                              attempt = attempt ? attempt + 1 : 1
                              yield select_server(cluster, server_selector, session)
                            rescue *retryable_exceptions, Error::OperationFailure, Error::PoolError => e
                              e.add_notes('legacy retry', "attempt #{attempt}")
                      Severity: Minor
                      Found in lib/mongo/retryable/read_worker.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 initialize has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def initialize(options)
                              Crypt.validate_ffi!
                              # Note that this call may eventually, via other method invocations,
                              # create additional clients which have to be cleaned up.
                              @options = set_default_options(options).freeze
                      Severity: Major
                      Found in lib/mongo/crypt/auto_encrypter.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language