File session.rb
has 563 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mongo/session/session_pool'
require 'mongo/session/server_session'
module Mongo
Class Session
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class Session
extend Forwardable
include Retryable
include Loggable
include ClusterTime::Consumer
Method with_transaction
has a Cognitive Complexity of 44 (exceeds 5 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
- 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_txn_opts!
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def add_txn_opts!(command, read)
command.tap do |c|
# The read concern should be added to any command that starts a transaction.
if starting_transaction?
# https://jira.mongodb.org/browse/SPEC-1161: transaction's
- 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 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 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 commit_transaction
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def commit_transaction(options=nil)
QueryCache.clear
check_if_ended!
check_if_no_transaction!
Method abort_transaction
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def abort_transaction
QueryCache.clear
check_if_ended!
check_if_no_transaction!
Method add_txn_opts!
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_txn_opts!(command, read)
command.tap do |c|
# The read concern should be added to any command that starts a transaction.
if starting_transaction?
# https://jira.mongodb.org/browse/SPEC-1161: transaction's
Method suppress_read_write_concern!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def suppress_read_write_concern!(command)
command.tap do |c|
next unless in_transaction?
c.delete(:readConcern) unless starting_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 start_transaction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_transaction(options = nil)
check_transactions_supported!
if options
Lint.validate_read_concern_option(options[:read_concern])
Method end_session
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def end_session
if !ended? && @client
if within_states?(TRANSACTION_IN_PROGRESS_STATE)
begin
abort_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 process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process(result)
unless implicit?
set_operation_time(result)
if cluster_time_doc = result.cluster_time
advance_cluster_time(cluster_time_doc)
- 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_preference!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_read_preference!(command)
return unless in_transaction?
return unless command['$readPreference']
mode = command['$readPreference']['mode'] || command['$readPreference'][: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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(server_session, client, options = {})
if options[:causal_consistency] && options[:snapshot]
raise ArgumentError, ':causal_consistency and :snapshot options cannot be both set on a session'
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 start_transaction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def start_transaction(options = nil)
check_transactions_supported!
if options
Lint.validate_read_concern_option(options[: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 check_transactions_supported!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_transactions_supported!
raise Mongo::Error::TransactionsNotSupported, "standalone topology" if cluster.single?
cluster.next_primary.with_connection do |conn|
if cluster.replica_set? && !conn.features.transactions_enabled?
- 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"