mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

Method delete_many has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def delete_many(documents, connection, context, operation_id, session, txn_num)
Severity: Minor
Found in lib/mongo/bulk_write.rb - About 45 mins to fix

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

          def validate_address_str!(address_str)
            case address_str
            when /\A\[[\d:]+\](?::(\d+))?\z/
              # ipv6 with optional port
              if port_str = $1
    Severity: Minor
    Found in lib/mongo/address/validator.rb - About 45 mins 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_write_with_retry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def legacy_write_with_retry(server = nil, context:)
            session = context.session
            context.check_timeout!
    
            # This is the pre-session retry logic, and is not subject to
    Severity: Minor
    Found in lib/mongo/retryable/write_worker.rb - About 45 mins 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 change_stream_resumable? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def change_stream_resumable?
              if @result && @result.is_a?(Mongo::Operation::GetMore::Result)
                # CursorNotFound exceptions are always resumable because the server
                # is not aware of the cursor id, and thus cannot determine if
                # the cursor is a change stream and cannot add the
    Severity: Minor
    Found in lib/mongo/error/operation_failure.rb - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(kms_providers)
              if kms_providers.nil?
                raise ArgumentError.new("KMS providers options must not be nil")
              end
              if kms_providers.key?(:aws)
    Severity: Minor
    Found in lib/mongo/crypt/kms/credentials.rb - About 45 mins 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 update_one has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def update_one(documents, connection, context, operation_id, session, txn_num)
    Severity: Minor
    Found in lib/mongo/bulk_write.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      unless key.to_s.start_with?("$")
                        if Mongo.validate_update_replace
                          raise Error::InvalidUpdateDocument.new(key: key)
                        else
                          Error::InvalidUpdateDocument.warn(Logger.logger, key)
      Severity: Major
      Found in lib/mongo/bulk_write.rb - About 45 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(host, port, host_name, timeout, family, options = {})
        Severity: Minor
        Found in lib/mongo/socket/ssl.rb - About 45 mins to fix

          Method delete_one has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def delete_one(documents, connection, context, operation_id, session, txn_num)
          Severity: Minor
          Found in lib/mongo/bulk_write.rb - About 45 mins to fix

            Method socket has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def socket(socket_timeout, opts = {})
                  csot = !!opts[:csot]
                  opts = {
                    connect_timeout: Server::CONNECT_TIMEOUT,
                  }.update(options).update(Hash[opts.map { |k, v| [k.to_sym, v] }])
            Severity: Minor
            Found in lib/mongo/address.rb - About 45 mins 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 connect_with_timeout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def connect_with_timeout(sockaddr, connect_timeout)
                    if connect_timeout <= 0
                      raise Error::SocketTimeoutError, "The socket took over #{connect_timeout} seconds to connect"
                    end
            
            
            Severity: Minor
            Found in lib/mongo/socket/tcp.rb - About 45 mins 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 set_cert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def set_cert(context, options)
                    # Since we clear cert_text during processing, we need to examine
                    # ssl_cert_object here to avoid considering it if we have also
                    # processed the text.
                    if options[:ssl_cert]
            Severity: Minor
            Found in lib/mongo/socket/ssl.rb - About 45 mins 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 insert_one has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def insert_one(documents, connection, context, operation_id, session, txn_num)
            Severity: Minor
            Found in lib/mongo/bulk_write.rb - About 45 mins to fix

              Method command_succeeded has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def command_succeeded(result, address, operation_id, payload, duration,
                      started_event:, server_connection_id: nil, service_id: nil
              Severity: Minor
              Found in lib/mongo/monitoring/publishable.rb - About 35 mins to fix

                Method generate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def self.generate(address, operation_id, command_payload,
                          reply_payload, duration, started_event:, server_connection_id: nil,
                          service_id: nil
                Severity: Minor
                Found in lib/mongo/monitoring/event/command_succeeded.rb - About 35 mins to fix

                  Method command_completed has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def command_completed(result, address, operation_id, payload, duration,
                          started_event:, server_connection_id: nil, service_id: nil
                  Severity: Minor
                  Found in lib/mongo/monitoring/publishable.rb - About 35 mins to fix

                    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def initialize(address, cluster, monitoring, event_listeners, options = {})
                    Severity: Minor
                    Found in lib/mongo/server.rb - About 35 mins to fix

                      Method create_encrypted_collection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def create_encrypted_collection(database, coll_name, coll_opts, kms_provider, master_key)
                      Severity: Minor
                      Found in lib/mongo/client_encryption.rb - About 35 mins to fix

                        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                              def initialize(host_name, cert, ca_cert, cert_store, **opts)
                        Severity: Minor
                        Found in lib/mongo/socket/ocsp_verifier.rb - About 35 mins to fix

                          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                def initialize(key_vault_client, key_vault_namespace, kms_providers, kms_tls_options, timeout_ms = nil)
                          Severity: Minor
                          Found in lib/mongo/crypt/explicit_encrypter.rb - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language