Showing 423 of 480 total issues
Method update_rs_without_primary
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_rs_without_primary
if topology.replica_set_name.nil?
@topology = Topology::ReplicaSetNoPrimary.new(
topology.options.merge(replica_set_name: updated_desc.replica_set_name),
topology.monitoring, self)
Method add_read_preference
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_read_preference(sel, connection)
Lint.assert_type(connection, Server::Connection)
# https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#topology-type-single
read_doc = if connection.description.standalone?
Method try_next
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try_next
if @documents.nil?
# Since published versions of Mongoid have a copy of old driver cursor
# code, our dup call in #process isn't invoked when Mongoid query
# cache is active. Work around that by also calling dup here on
Method check
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check
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!
@connection = nil
- 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_concern_option
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_read_concern_option(read_concern)
return unless enabled?
return if read_concern.nil?
unless read_concern.is_a?(Hash)
raise Error::LintError, "Read concern is not a hash: #{read_concern}"
- 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 credentials_valid?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def credentials_valid?(credentials, source)
unless credentials.access_key_id || credentials.secret_access_key ||
credentials.session_token
then
return false
- 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 ec2_metadata_credentials
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ec2_metadata_credentials(timeout_holder = nil)
timeout_holder&.check_timeout!
http = Net::HTTP.new('169.254.169.254')
req = Net::HTTP::Put.new('/latest/api/token',
# The TTL is required in order to obtain the metadata token.
- 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 wait_for_connection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_connection(connection_global_id, deadline)
connection = nil
while connection.nil?
# The second gate to checking out a connection. Make sure 1) there
# exists an available connection and 2) we are under max_connecting.
- 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 add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add(host, add_options=nil)
address = Address.new(host, options)
if !addresses.include?(address)
opts = options.merge(monitor: false)
# If we aren't starting the montoring threads, we also don't want to
- 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 retrieve_and_connect_connection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_and_connect_connection(connection_global_id, context = nil)
deadline = Utils.monotonic_time + wait_timeout(context)
connection = nil
@lock.synchronize do
- 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 add_read_preference_legacy
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_read_preference_legacy(sel, connection)
if read && (
connection.description.mongos? || connection.description.load_balancer?
) && read_pref = read.to_mongos
# If the read preference contains only mode and mode is secondary
- 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 command
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def command(connection)
if Lint.enabled?
unless connection.is_a?(Server::Connection)
raise Error::LintError, "Connection is not a Connection instance: #{connection}"
end
- 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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def each
@cursor = nil
session = client.get_session(@options)
server = cluster.next_primary(nil, session)
context = Operation::Context.new(client: client, session: session, operation_timeouts: view.operation_timeouts)
- 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 parse_password!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_password!(string)
if (string && pwd = string.partition(AUTH_USER_PWD_DELIM)[2])
if pwd.length > 0
raise_invalid_error!(UNESCAPED_USER_PWD) if pwd =~ UNSAFE
pwd_decoded = decode(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 update_many
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_many(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 effective_read_preference
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def effective_read_preference(connection)
return unless view.read_preference
return view.read_preference unless write?
return view.read_preference unless [:secondary, :secondary_preferred].include?(view.read_preference[:mode])
- 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!
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 replace_one
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def replace_one(replacement, 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"