Showing 197 of 236 total issues
Method destroy
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def destroy(options = nil)
raise Errors::ReadonlyDocument.new(self.class) if readonly?
self.flagged_for_destroy = true
result = run_callbacks(:commit, skip_if: -> { in_transaction? }) do
run_callbacks(:destroy) 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 with_session
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def with_session(options = {})
if Threaded.get_session(client: persistence_context.client)
raise Mongoid::Errors::InvalidSessionNesting.new
end
session = persistence_context.client.start_session(options)
- 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 _handle_callbacks_after_instantiation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _handle_callbacks_after_instantiation(execute_callbacks)
if execute_callbacks
apply_defaults
yield self if block_given?
run_callbacks(:find) unless _find_callbacks.empty?
- 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 extract_attribute
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
module_function def extract_attribute(document, key)
if document.respond_to?(:as_attributes, true)
# If a document has hash fields, as_attributes would keep those fields
# as Hash instances which do not offer indifferent access.
# Convert to BSON::Document to get indifferent access on hash fields.
Method mul
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def mul(factors)
prepare_atomic_operation do |ops|
process_atomic_operations(factors) do |field, value|
factor = value.is_a?(BigDecimal) ? value.to_f : value
current = attributes[field]
- 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 demongoize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def demongoize(object)
return if object.blank?
time = if object.acts_like?(:time)
Mongoid::Config.use_utc? ? object : object.getlocal
elsif object.acts_like?(:date)
- 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 prepare_arguments
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def prepare_arguments(kms_provider_name, client_name)
client = (client_name || 'default').to_s
client_options = Mongoid.clients[client]
unless client_options.is_a?(Hash)
raise Errors::NoClientConfig.new(client)
- 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 any_of
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def any_of(*criteria)
criteria = _mongoid_flatten_arrays(criteria)
case criteria.length
when 0
clone
- 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 inc
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def inc(increments)
prepare_atomic_operation do |ops|
process_atomic_operations(increments) do |field, value|
increment = value.is_a?(BigDecimal) ? value.to_f : value
current = attributes[field]
- 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 create!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create!(attributes = nil, &block)
_creating do
if attributes.is_a?(::Array)
attributes.map { |attrs| create!(attrs, &block) }
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"
Further reading
Method add_atomic_changes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_atomic_changes(document, name, key, mods, new_elements, old_elements)
old = (old_elements || [])
new = (new_elements || [])
if new.length > old.length
if new.first(old.length) == old
- 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 write_attribute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_attribute(name, value)
validate_writable_field_name!(name.to_s)
field_name = database_field_name(name)
Method create_collection
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_collection(force: false)
if collection_name.empty?
# This is most probably an anonymous class, we ignore them.
return
end
Method create_collection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create_collection(force: false)
if collection_name.empty?
# This is most probably an anonymous class, we ignore them.
return
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 update_nested_relation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_nested_relation(parent, id, attrs)
first = existing.first
converted = first ? convert_id(first.class, id) : id
if existing.where(_id: converted).exists?
- 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 batch_remove
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def batch_remove(docs, method = :delete)
# If the _id is nil, we cannot use $pull and delete by searching for
# the id. Therefore we have to use pullAll with the documents'
# attributes.
removals = pre_process_batch_remove(docs, method)
- 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 bind_one
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def bind_one
binding do
check_polymorphic_inverses!(_target)
bind_foreign_key(_base, record_id(_target))
bind_polymorphic_inverse_type(_base, _target.class.name)
- 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 define_setter!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.define_setter!(association)
name = association.name
association.inverse_class.tap do |klass|
klass.re_define_method("#{name}=") do |object|
without_autobuild 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 get_relation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_relation(name, association, object, reload = false)
field_name = database_field_name(name)
# As per the comments under MONGOID-5034, I've decided to only raise on
# embedded associations for a missing attribute. Rails does not raise
- 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 batch_replace
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def batch_replace(docs)
if docs.blank?
if _assigning? && !empty?
_base.delayed_atomic_sets.delete(path)
clear_atomic_path_cache
- 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"