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)
- Read upRead up
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)
- Read upRead up
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,
- Read upRead up
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
- Read upRead up
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
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
Method close
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def close(options = nil)
return if closed?
options ||= {}
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 || {})
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
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?
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] }])
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
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)
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)
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
- Read upRead up
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
- Read upRead up
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.
- Read upRead up
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 || {})
- Read upRead up
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]
- Read upRead up
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!
- Read upRead up
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"