Showing 393 of 447 total issues
Method initialize
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(seeds, monitoring, options = Options::Redacted.new)
if seeds.nil?
raise ArgumentError, 'Seeds cannot be nil'
end
Method change_doc
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def change_doc
{}.tap do |doc|
if @options[:full_document]
doc[:fullDocument] = @options[:full_document]
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
File uri.rb
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongo
# The URI class provides a way for users to parse the MongoDB uri as
# defined in the connection string format spec.
#
File writable.rb
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongo
class Collection
class View
# Defines write related behavior for collection view.
Method server_description_changed
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def server_description_changed
@previous_server_descriptions = servers_list.map do |server|
[server.address.to_s, server.description]
end
Class Result
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Result
extend Forwardable
include Enumerable
# The field name for the cursor document in an aggregation.
Method with_transaction
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def with_transaction(options=nil)
# Non-configurable 120 second timeout for the entire operation
deadline = Utils.monotonic_time + 120
transaction_in_progress = false
loop do
Method parse!
has a Cognitive Complexity of 22 (exceeds 5 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
- 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 estimated_document_count
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def estimated_document_count(opts = {})
unless view.filter.empty?
raise ArgumentError, "Cannot call estimated_document_count when querying with a filter"
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 initialize
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options)
Crypt.validate_ffi!
# Note that this call may eventually, via other method invocations,
# create additional clients which have to be cleaned up.
@options = set_default_options(options).freeze
- 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
File description.rb
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongo
class Server
# Represents a description of the server, populated by the result of the
# hello command.
Class ScramConversationBase
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ScramConversationBase < SaslConversationBase
# The minimum iteration count for SCRAM-SHA-1 and SCRAM-SHA-256.
MIN_ITER_COUNT = 4096
Method commit_transaction
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def commit_transaction(options=nil)
QueryCache.clear
check_if_ended!
check_if_no_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 validate_uri_options!
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_uri_options!
# The URI options spec requires that we raise an error if there are conflicting values of
# 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
# array; assuming all values in the array are the same, we replace the array with that value.
unless uri_options[:ssl].nil? || uri_options[:ssl].empty?
Method read_from_socket
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_from_socket(length, timeout: nil)
# Just in case
if length == 0
return ''.force_encoding('BINARY')
end
Method run_sdam_flow
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def run_sdam_flow(previous_desc, updated_desc, options = {})
if load_balanced?
if updated_desc.config.empty?
unless options[:keep_connection_pool]
servers_list.each do |server|
- 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 initial
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def initial(cluster, monitoring, options)
connect = options[:connect]&.to_sym
cls = if options[:direct_connection]
if connect && connect != :direct
raise ArgumentError, "Conflicting topology options: direct_connection=true and connect=#{connect}"
- 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 kill_cursors
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def kill_cursors
# TODO optimize this to batch kill cursor operations for the same
# server/database/collection instead of killing each cursor
# individually.
loop 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 legacy_read_with_retry
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def legacy_read_with_retry(session, server_selector, &block)
attempt = attempt ? attempt + 1 : 1
yield select_server(cluster, server_selector, session)
rescue *retryable_exceptions, Error::OperationFailure, Error::PoolError => e
e.add_notes('legacy retry', "attempt #{attempt}")
- 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 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options)
Crypt.validate_ffi!
# Note that this call may eventually, via other method invocations,
# create additional clients which have to be cleaned up.
@options = set_default_options(options).freeze