mongodb/mongo-ruby-driver

View on GitHub

Showing 447 of 447 total issues

Method build_message has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def build_message
        errors = @result['writeErrors']
        return nil unless errors

        fragment = ""
Severity: Minor
Found in lib/mongo/error/bulk_write_error.rb - About 1 hr 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 find_one_and_delete has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def find_one_and_delete(opts = {})
          with_session(opts) do |session|
            write_concern = if opts[:write_concern]
              WriteConcern.get(opts[:write_concern])
            else
Severity: Minor
Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

    Method parallel_scan has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def parallel_scan(cursor_count, options = {})
              if options[:session]
                # The session would be overwritten by the one in +options+ later.
                session = client.send(:get_session, @options)
              else
    Severity: Minor
    Found in lib/mongo/collection/view/readable.rb - About 1 hr to fix

      Method deserialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.deserialize(io,
              max_message_size = MAX_MESSAGE_SIZE,
              expected_response_to = nil,
              options = {}
            )
      Severity: Minor
      Found in lib/mongo/protocol/message.rb - About 1 hr to fix

        Method execute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def execute
              operation_id = Monitoring.next_operation_id
              result_combiner = ResultCombiner.new
              operations = op_combiner.combine
              validate_requests!
        Severity: Minor
        Found in lib/mongo/bulk_write.rb - About 1 hr to fix

          Method server_version_gte? has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def server_version_gte?(version)
                  required_wv = case version
                    when '7.0'
                      21
                    when '6.0'
          Severity: Minor
          Found in lib/mongo/server/description.rb - About 1 hr to fix

            Method do_check_in has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def do_check_in(connection)
                    # When a connection is interrupted it is checked back into the pool
                    # and closed. The operation that was using the connection before it was
                    # interrupted will attempt to check it back into the pool, and we
                    # should ignore it since its already been closed and removed from the pool.
            Severity: Minor
            Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

              Method run_sdam_flow has 33 lines of code (exceeds 25 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 1 hr to fix

                Method handshake! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def handshake!(speculative_auth_doc: nil)
                        unless socket
                          raise Error::InternalDriverError, "Cannot handshake because there is no usable socket (for #{address})"
                        end
                
                
                Severity: Minor
                Found in lib/mongo/server/pending_connection.rb - About 1 hr to fix

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

                            def initialize(opts)
                              @opts = opts
                              return if empty?
                  
                              if opts[:access_token]
                  Severity: Minor
                  Found in lib/mongo/crypt/kms/gcp/credentials.rb - About 1 hr to fix

                    Method delete_one has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def delete_one(opts = {})
                              with_session(opts) do |session|
                                write_concern = if opts[:write_concern]
                                  WriteConcern.get(opts[:write_concern])
                                else
                    Severity: Minor
                    Found in lib/mongo/collection/view/writable.rb - About 1 hr to fix

                      Method publish_heartbeat has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def publish_heartbeat(server, awaited: false)
                            if monitoring?
                              started_event = Event::ServerHeartbeatStarted.new(
                                server.address, awaited: awaited)
                              started(SERVER_HEARTBEAT, started_event)
                      Severity: Minor
                      Found in lib/mongo/monitoring.rb - About 1 hr to fix

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

                              def initialize(kms_providers, kms_tls_options, options={})
                                # FFI::AutoPointer uses a custom release strategy to automatically free
                                # the pointer once this object goes out of scope
                                @mongocrypt = FFI::AutoPointer.new(
                                  Binding.mongocrypt_new,
                        Severity: Minor
                        Found in lib/mongo/crypt/handle.rb - About 1 hr to fix

                          Method create_and_add_connection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def create_and_add_connection
                                  connection = nil
                          
                                  @lock.synchronize do
                                    if !closed? && @ready &&
                          Severity: Minor
                          Found in lib/mongo/server/connection_pool.rb - About 1 hr 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 do_clear has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def do_clear(options = nil)
                                  check_invariants
                          
                                  service_id = options && options[:service_id]
                          
                          
                          Severity: Minor
                          Found in lib/mongo/server/connection_pool.rb - About 1 hr 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_available_connections has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def close_available_connections(service_id)
                                  if @server.load_balancer? && service_id
                                    loop do
                                      conn = @available_connections.detect do |conn|
                                        conn.service_id == service_id &&
                          Severity: Minor
                          Found in lib/mongo/server/connection_pool.rb - About 1 hr 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_read! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def validate_read!(option, opts)
                                if option == :read && opts.has_key?(:read)
                                  read = opts[:read]
                                  # We could check if read is a Hash, but this would fail
                                  # for custom classes implementing key access ([]).
                          Severity: Minor
                          Found in lib/mongo/client.rb - About 1 hr 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 deliver has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def deliver(message, context, options = {})
                                  if Lint.enabled? && !@socket
                                    raise Error::LintError, "Trying to deliver a message over a disconnected connection (to #{address})"
                                  end
                                  buffer = serialize(message, context)
                          Severity: Minor
                          Found in lib/mongo/server/connection_base.rb - About 1 hr 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 suppress_read_write_concern! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def suppress_read_write_concern!(command)
                                command.tap do |c|
                                  next unless in_transaction?
                          
                                  c.delete(:readConcern) unless starting_transaction?
                          Severity: Minor
                          Found in lib/mongo/session.rb - About 1 hr 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 collections_info_spec has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def collections_info_spec(session, options = {})
                                  { selector: {
                                      listCollections: 1,
                                      cursor: batch_size ? { batchSize: batch_size } : {} },
                                    db_name: @database.name,
                          Severity: Minor
                          Found in lib/mongo/database/view.rb - About 1 hr 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