Showing 423 of 480 total issues
Method read_from_socket
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_from_socket(length, socket_timeout: nil, csot: false)
# 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 legacy_read_with_retry
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def legacy_read_with_retry(session, server_selector, context = nil, &block)
context&.check_timeout!
attempt = attempt ? attempt + 1 : 1
yield select_server(cluster, server_selector, session)
rescue *legacy_retryable_exceptions, Error::OperationFailure::Family => e
- 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
Class Base
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
# Initialize the server selector.
#
# @example Initialize the selector.
Class MapReduce
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class MapReduce
extend Forwardable
include Enumerable
include Immutable
include Loggable
Method update_rs_from_primary
has 66 lines of code (exceeds 25 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)
Method initialize
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options, monitoring, cluster)
options = validate_options(options, cluster)
@options = options
@monitoring = monitoring
- 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 stale_primary?
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def stale_primary?
if updated_desc.max_wire_version >= 17
if updated_desc.election_id.nil? && !topology.max_election_id.nil?
return true
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 collection.rb
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mongo/bulk_write'
require 'mongo/collection/view'
require 'mongo/collection/helpers'
require 'mongo/collection/queryable_encryption'
Class FSBucket
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class FSBucket
extend Forwardable
# The default root prefix.
#
Class Message
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Message
include Id
include Serializers
# The batch size constant.
Method validate_timeout_mode!
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def validate_timeout_mode!(options, forbid: [])
forbid.each do |key|
raise ArgumentError, "#{key} is not allowed here" if options.key?(key)
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 validate_new_options!
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_new_options!(opts)
return Options::Redacted.new unless opts
if opts[:read_concern]
# Raise an error for non user-settable options
if opts[:read_concern][:after_cluster_time]
Class ChangeStream
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ChangeStream
include Aggregation::Behavior
include Retryable
# @return [ String ] The fullDocument option default value.
Class BulkWrite
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class BulkWrite
extend Forwardable
include Operation::ResponseHandling
# @return [ Mongo::Collection ] collection The collection.
Class SSL
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class SSL < Socket
include OpenSSL
# Initializes a new TLS socket.
#
Method ruby_to_string
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def ruby_to_string(opts)
rv = {}
URI_OPTION_MAP.each do |uri_key, spec|
if spec[:group]
v = opts[spec[:group]]
- 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 ruby_to_smc
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def ruby_to_smc(opts)
rv = {}
URI_OPTION_MAP.each do |uri_key, spec|
if spec[:group]
v = opts[spec[:group]]
- 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"