Showing 447 of 447 total issues
Method update_rs_with_primary_from_member
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_rs_with_primary_from_member
if topology.replica_set_name != updated_desc.replica_set_name
log_warn(
"Removing server #{updated_desc.address.to_s} because it has an " +
"incorrect replica set name (#{updated_desc.replica_set_name}); " +
Method initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user, used_mechanism: nil, message: nil,
server: nil, code: nil
)
@code = code
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 spawn_mongocryptd
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def spawn_mongocryptd
mongocryptd_spawn_args = @options[:mongocryptd_spawn_args]
mongocryptd_spawn_path = @options[:mongocryptd_spawn_path]
unless mongocryptd_spawn_path
Method validate_param
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_param(key, opts, format_hint, required: true)
value = opts.fetch(key)
return nil if value.nil? && !required
if value.nil?
raise ArgumentError.new(
Method ruby_to_string
has 29 lines of code (exceeds 25 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]]
Method ruby_to_smc
has 29 lines of code (exceeds 25 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]]
Method create_context
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_context(options)
OpenSSL::SSL::SSLContext.new.tap do |context|
if OpenSSL::SSL.const_defined?(:OP_NO_RENEGOTIATION)
context.options = context.options | OpenSSL::SSL::OP_NO_RENEGOTIATION
end
Method normalized?
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.normalized?(string, form = :nfc)
encoding = string.encoding
case encoding
when Encoding::UTF_8
case form
Method do_clear
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_clear(options = nil)
check_invariants
service_id = options && options[:service_id]
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(address, config = {}, average_round_trip_time: nil,
load_balancer: false, force_load_balancer: false
)
@address = address
@config = config
Method try_next
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try_next
if @documents.nil?
# Since published versions of Mongoid have a copy of old driver cursor
# code, our dup call in #process isn't invoked when Mongoid query
# cache is active. Work around that by also calling dup here on
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 update_rs_without_primary
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_rs_without_primary
if topology.replica_set_name.nil?
@topology = Topology::ReplicaSetNoPrimary.new(
topology.options.merge(replica_set_name: updated_desc.replica_set_name),
topology.monitoring, self)
Method distinct
has 28 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 add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add(host, add_options=nil)
address = Address.new(host, options)
if !addresses.include?(address)
opts = options.merge(monitor: false)
# If we aren't starting the montoring threads, we also don't want to
- 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 wait_for_connection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_connection(connection_global_id, deadline)
connection = nil
while connection.nil?
# The second gate to checking out a connection. Make sure 1) there
# exists an available connection and 2) we are under max_connecting.
- 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 ec2_metadata_credentials
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ec2_metadata_credentials
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.
{'x-aws-ec2-metadata-token-ttl-seconds' => '30'})
- 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 retrieve_and_connect_connection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_and_connect_connection(connection_global_id)
deadline = Utils.monotonic_time + wait_timeout
connection = nil
@lock.synchronize 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 credentials_valid?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def credentials_valid?(credentials, source)
unless credentials.access_key_id || credentials.secret_access_key ||
credentials.session_token
then
return false
- 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"