Showing 447 of 447 total issues
Method run_state_machine
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run_state_machine
while true
case state
when :error
Binding.check_ctx_status(self)
- 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 find_one_and_update
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_one_and_update(document, opts = {})
value = with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method download_url
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def download_url
@download_url ||= begin
info = JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
version = info['versions'].detect do |version|
version['version'].start_with?(desired_version) &&
Method initialize
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options, monitoring, cluster)
options = validate_options(options, cluster)
@options = options
@monitoring = monitoring
Method update_one
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_one(spec, opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method update_many
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_many(spec, opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method replace_one
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def replace_one(replacement, opts = {})
with_session(opts) do |session|
write_concern = if opts[:write_concern]
WriteConcern.get(opts[:write_concern])
else
Method ec2_metadata_credentials
has 36 lines of code (exceeds 25 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'})
Method check
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check
if @connection && @connection.pid != Process.pid
log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{@connection.pid}, new pid #{Process.pid}")
@connection.disconnect!
@connection = nil
Method parse!
has 36 lines of code (exceeds 25 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
Method estimated_document_count
has 36 lines of code (exceeds 25 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
Method start_stop_srv_monitor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def start_stop_srv_monitor
# SRV URI is either always given or not for a given cluster, if one
# wasn't given we shouldn't ever have an SRV monitor to manage.
return unless options[:srv_uri]
- 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 close
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def close
@state_change_lock.synchronize do
unless connecting? || connected?
return nil
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 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(server, options = {})
unless server.is_a?(Server)
raise ArgumentError, 'First argument must be a Server instance'
end
options = options.dup
- 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 do_check_in
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def do_check_in(connection)
# When a connection is interrupted it is checked back into the pool
# and closed. The operation that was using the connection before it was
# interrupted will attempt to check it back into the pool, and we
# should ignore it since its already been closed and removed from the pool.
- 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 connect!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def connect!
raise_if_closed!
unless @socket
@socket = create_socket
- 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 try_select_server
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def try_select_server(cluster, write_aggregation: false, deprioritized: [])
servers = if write_aggregation && cluster.replica_set?
# 1. Check if ALL servers in cluster support secondary writes.
is_write_supported = cluster.servers.reduce(true) do |res, server|
res && server.features.merge_out_on_secondary_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"
Further reading
Method try_next
has a Cognitive Complexity of 12 (exceeds 5 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
- 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 smc_to_ruby
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def smc_to_ruby(opts)
uri_options = {}
opts.each do |key, value|
strategy = URI_OPTION_MAP[key.downcase]
- 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_length!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def validate_length!(index, num_chunks, chunk, length_read)
if num_chunks > 0 && chunk.data.data.size > 0
raise Error::ExtraFileChunk.new unless index < num_chunks
if index == num_chunks - 1
unless chunk.data.data.size + length_read == file_info.length
- 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"