Showing 423 of 480 total issues
Method find_one_and_update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_one_and_update(document, opts = {})
value = 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 reconstruct_uri
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def reconstruct_uri
servers = @servers.join(',')
options = options_mapper.ruby_to_string(@uri_options).map do |k, vs|
unless vs.nil?
if vs.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 update_rs_from_primary
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update_rs_from_primary
if topology.replica_set_name.nil?
@topology = Topology::ReplicaSetWithPrimary.new(
topology.options.merge(replica_set_name: updated_desc.replica_set_name),
topology.monitoring, self)
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(replies, connection_description, connection_global_id, ids)
@replies = [*replies] if replies
@connection_description = connection_description
@connection_global_id = connection_global_id
if replies && replies.first && (doc = replies.first.documents.first)
- 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 try_next
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def try_next
recreate_cursor! if @timed_out
raise StopIteration.new if closed?
- 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 find_command
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_command
document = BSON::Document.new(
find: collection,
filter: query_filter,
)
- 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 run_state_machine
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run_state_machine(timeout_holder)
while true
timeout_ms = timeout_holder.remaining_timeout_ms!
case state
when :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 parse_code
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_code
if document['ok'] == 1 || @options[:legacy]
@code = @code_name = nil
else
@code = document['code']
- 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 find_one_and_delete
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_one_and_delete(opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method initialize
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options, monitoring, cluster)
options = validate_options(options, cluster)
@options = options
@monitoring = monitoring
Method handshake!
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handshake!(speculative_auth_doc: nil)
unless socket
raise Error::InternalDriverError, "Cannot handshake because there is no usable socket (for #{address})"
end
Method ec2_metadata_credentials
has 37 lines of code (exceeds 25 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.
Method retry_read
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def retry_read(original_error, session, server_selector, context: nil, failed_server: nil, &block)
server = select_server_for_retry(
original_error, session, server_selector, context, failed_server
)
Method create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create(opts = {})
# Passing read options to create command causes it to break.
# Filter the read options out. Session is also excluded here as it gets
# used by the call to with_session and should not be part of the
# operation. If it gets passed to the operation it would fail BSON
Method check
has 36 lines of code (exceeds 25 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
Method parse!
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse!(remaining)
hosts_and_db, options = remaining.split('?', 2)
if options && options.index('?')
raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
end
Method distinct
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def distinct(field_name, opts = {})
if field_name.nil?
raise ArgumentError, 'Field name for distinct operation must be not nil'
end
opts = @options.merge(opts) unless Mongo.broken_view_options
Method delete_one
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_one(opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method initial_query_op
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initial_query_op(session)
spec = {
coll_name: collection.name,
filter: filter,
projection: projection,
Method read_with_timeout
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def read_with_timeout(length, timeout)
deadline = Utils.monotonic_time + timeout
map_exceptions do
String.new.tap do |data|
while data.length < 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"