Showing 423 of 480 total issues
Method close
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def close(options = nil)
return if closed?
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 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 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 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 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 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_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 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 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 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 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 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 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 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 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 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 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 do_check_in
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def do_check_in(connection)
# When a connection is interrupted it is checked back into the pool
# and closed. The operation that was using the connection before it was
# interrupted will attempt to check it back into the pool, and we
# should ignore it since its already been closed and removed from the pool.
- 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"