Method add_read_preference
has a Cognitive Complexity of 15 (exceeds 5 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?
- 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
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 apply_session_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def apply_session_options(sel, connection)
apply_cluster_time!(sel, connection)
sel[:txnNumber] = BSON::Int64.new(txn_num) if txn_num
sel.merge!(lsid: session.session_id)
apply_start_transaction!(sel)
- 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 build_message
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build_message(connection, context)
if self.session != context.session
if self.session
raise Error::InternalDriverError, "Operation session #{self.session.inspect} does not match context session #{context.session.inspect}"
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"