Showing 393 of 447 total issues
Method validate!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate!
if !@tag_sets.all? { |set| set.empty? } && !tags_allowed?
raise Error::InvalidServerPreference.new(Error::InvalidServerPreference::NO_TAG_SUPPORT)
elsif @max_staleness && !max_staleness_allowed?
raise Error::InvalidServerPreference.new(Error::InvalidServerPreference::NO_MAX_STALENESS_SUPPORT)
- 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_one
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_one(spec, opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get(**opts)
limit = normalized_limit(opts[:limit])
_namespace_key = namespace_key(**opts)
_cache_key = cache_key(**opts)
- 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(replies, connection_description = nil, connection_global_id = nil)
if replies
if replies.is_a?(Array)
if replies.length != 1
raise ArgumentError, "Only one (or zero) reply is supported, given #{replies.length}"
- 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 each
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def each
# If the caching cursor is closed and was not fully iterated,
# the documents we have in it are not the complete result set and
# we have no way of completing that iteration.
# Therefore, discard that cursor and start iteration again.
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 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 insert_one
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def insert_one(document, opts = {})
QueryCache.clear_namespace(namespace)
client.with_session(opts) do |session|
write_concern = if opts[:write_concern]
Method close
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def close(options = nil)
return if closed?
options ||= {}
Method count
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count(opts = {})
opts = @options.merge(opts) unless Mongo.broken_view_options
cmd = { :count => collection.name, :query => filter }
cmd[:skip] = opts[:skip] if opts[:skip]
cmd[:hint] = opts[:hint] if opts[:hint]
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 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 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 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"
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"