mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

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

      def initialize(replies, connection_description = nil, connection_global_id = nil, context: nil, connection: nil)
        @context = context

        if replies
          if replies.is_a?(Array)
Severity: Minor
Found in lib/mongo/operation/result.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 apply_session_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def apply_session_options(sel, connection)
        apply_cluster_time!(sel, connection)
        sel[:txnNumber] = BSON::Int64.new(txn_num) if txn_num
        sel.merge!(lsid: session.session_id)
        apply_start_transaction!(sel)
Severity: Minor
Found in lib/mongo/operation/shared/sessions_supported.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 initialize has a Cognitive Complexity of 10 (exceeds 5 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

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 to_document has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def to_document
          BSON::Document.new.tap do |bson|
            bson[:aws] = @aws.to_document if @aws
            bson[:azure] = @azure.to_document if @azure
            bson[:gcp] = @gcp.to_document if @gcp
Severity: Minor
Found in lib/mongo/crypt/kms/credentials.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 get_records has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def get_records(hostname, srv_service_name=nil, srv_max_hosts=nil)
        query_name = record_prefix(srv_service_name) + hostname
        resources = @resolver.getresources(query_name, Resolv::DNS::Resource::IN::SRV)

        # Collect all of the records into a Result object, raising an error
Severity: Minor
Found in lib/mongo/srv/resolver.rb - About 1 hr to fix

    Method connect! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def connect!
            sockaddr = ::Socket.pack_sockaddr_in(port, host)
            connect_timeout = options[:connect_timeout]
            map_exceptions do
              if connect_timeout && connect_timeout != 0
    Severity: Minor
    Found in lib/mongo/socket/ssl.rb - About 1 hr to fix

      Method close has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def close(options = nil)
              return if closed?
      
              options ||= {}
      
      
      Severity: Minor
      Found in lib/mongo/server/connection_pool.rb - About 1 hr to fix

        Method update_options has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def update_options(new_options)
              old_options = @options
        
              new_options = self.class.canonicalize_ruby_options(new_options || {})
        
        
        Severity: Minor
        Found in lib/mongo/client.rb - About 1 hr to fix

          Method stale_primary? has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def stale_primary?
                if updated_desc.max_wire_version >= 17
                  if updated_desc.election_id.nil? && !topology.max_election_id.nil?
                    return true
                  end
          Severity: Minor
          Found in lib/mongo/cluster/sdam_flow.rb - About 1 hr to fix

            Method command has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def command(operation, opts = {})
                  opts = opts.dup
                  execution_opts = opts.delete(:execution_options) || {}
            
                  txn_read_pref = if opts[:session] && opts[:session].in_transaction?
            Severity: Minor
            Found in lib/mongo/database.rb - About 1 hr to fix

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

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

                        def initialize(command_name, database_name, address,
                          request_id, operation_id, message, failure, duration,
                          started_event:, server_connection_id: nil, service_id: nil
                Severity: Major
                Found in lib/mongo/monitoring/event/command_failed.rb - About 1 hr to fix

                  Method split_execute has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def split_execute(name, values, connection, context, operation_id, result_combiner, session, txn_num)
                  Severity: Major
                  Found in lib/mongo/bulk_write.rb - About 1 hr to fix

                    Method execute_operation has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def execute_operation(name, values, connection, context, operation_id, result_combiner, session, txn_num = nil)
                    Severity: Major
                    Found in lib/mongo/bulk_write.rb - About 1 hr to fix

                      Method checkout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def checkout
                              @mutex.synchronize do
                                loop do
                                  if @queue.empty?
                                    return ServerSession.new
                      Severity: Minor
                      Found in lib/mongo/session/session_pool.rb - About 55 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 unknown! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def unknown!(options = {})
                            pool = pool_internal
                      
                            if load_balancer?
                              # When the client is in load-balanced topology, servers (the one and
                      Severity: Minor
                      Found in lib/mongo/server.rb - About 55 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 do_work has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def do_work
                              scan!
                              # @next_wanted_scan may be updated by the push monitor.
                              # However we need to check for termination flag so that the monitor
                              # thread exits when requested.
                      Severity: Minor
                      Found in lib/mongo/server/monitor.rb - About 55 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_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def update_options(new_options)
                            old_options = @options
                      
                            new_options = self.class.canonicalize_ruby_options(new_options || {})
                      
                      
                      Severity: Minor
                      Found in lib/mongo/client.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def initialize(options)
                              @database = options[:database] || Database::ADMIN
                              @auth_source = options[:auth_source] || self.class.default_auth_source(options)
                              @name = options[:user]
                              @password = options[:password] || options[:pwd]
                      Severity: Minor
                      Found in lib/mongo/auth/user.rb - About 55 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 check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def check
                              @lock.synchronize do
                                if @connection && @connection.pid != Process.pid
                                  log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{@connection.pid}, new pid #{Process.pid}")
                                  @connection.disconnect!
                      Severity: Minor
                      Found in lib/mongo/server/push_monitor.rb - About 55 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

                      Severity
                      Category
                      Status
                      Source
                      Language