Showing 423 of 480 total issues
Method retry_write
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def retry_write(original_error, txn_num, context:, failed_server: nil, &block)
context&.check_timeout!
session = context.session
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,
Method legacy_write_with_retry
has 32 lines of code (exceeds 25 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
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 &&
- 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_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]
- 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 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)
- 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 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 &&
- 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 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 ([]).
- 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 convert_limit_and_batch_size!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
module_function def convert_limit_and_batch_size!(command)
if command[:limit] && command[:limit] < 0 &&
command[:batchSize] && command[:batchSize] < 0
then
command[:limit] = command[:limit].abs
- 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 validate_update_documents!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_update_documents!(spec)
if update = spec.is_a?(Array) ? spec&.first : spec
if key = update.keys&.first
unless key.to_s.start_with?("$")
if Mongo.validate_update_replace
- 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 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?
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(flags, options, main_document, *sequences)
if flags
flags.each do |flag|
unless KNOWN_FLAGS.key?(flag)
raise ArgumentError, "Unknown flag: #{flag.inspect}"
- 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 maybe_set_schema_map
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def maybe_set_schema_map(options)
if !options[:schema_map] && !options[:schema_map_path]
@schema_map = nil
elsif options[:schema_map] && options[:schema_map_path]
raise ArgumentError.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 get_records
has a Cognitive Complexity of 11 (exceeds 5 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
- 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 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,
- 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 set_algorithm_opts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def set_algorithm_opts(options)
Binding.ctx_setopt_algorithm(self, options[:algorithm])
if %w(Indexed RangePreview).include?(options[:algorithm])
if options[:contention_factor]
Binding.ctx_setopt_contention_factor(self, options[:contention_factor])
- 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 create_and_add_connection
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_and_add_connection
connection = nil
@lock.synchronize do
if !closed? && @ready &&
Method close
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def close
@state_change_lock.synchronize do
unless connecting? || connected?
return nil
end
Method check
has 31 lines of code (exceeds 25 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!
Method initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(address, cluster, monitoring, event_listeners, options = {})
@address = address
@cluster = cluster
@monitoring = monitoring
options = options.dup