Showing 197 of 236 total issues
Method set_max
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_max(fields)
prepare_atomic_operation do |ops|
process_atomic_operations(fields) do |field, value|
current_value = attributes[field]
if value > current_value
- 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 criterion
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def criterion(document, attribute, value)
field = document.database_field_name(attribute)
if value && localized?(document, field)
conditions = (value || {}).inject([]) { |acc, (k,v)| acc << { "#{field}.#{k}" => filter(v) }}
- 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 saved_change_to_attribute?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def saved_change_to_attribute?(attr, from: Utils::PLACEHOLDER, to: Utils::PLACEHOLDER)
changes = saved_change_to_attribute(attr)
return false unless changes.is_a?(Array)
return true if Utils.placeholder?(from) && Utils.placeholder?(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 concat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def concat(documents)
docs, inserts = [], []
documents.each do |doc|
next unless 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 bind_one
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bind_one
binding do
check_polymorphic_inverses!(_target)
_base._association = _association.inverse_association(_target) unless _base._association
_base.parentize(_target)
- 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 reload_relations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def reload_relations
relations.each_pair do |name, meta|
if instance_variable_defined?("@_#{name}")
if _parent.nil? || instance_variable_get("@_#{name}") != _parent
remove_instance_variable("@_#{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 in
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def in(condition)
if condition.nil?
raise Errors::CriteriaArgumentRequired, :in
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 retrieve_and_validate_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_and_validate_type(name, type)
result = TYPE_MAPPINGS[type] || unmapped_type(type)
raise Errors::InvalidFieldType.new(self, name, type) if !result.is_a?(Class)
if unsupported_type?(result)
- 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 clear_target_for_nullify
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clear_target_for_nullify
after_remove_error = nil
many_to_many = _target.clear do |doc|
unbind_one(doc)
doc.changed_attributes.delete(inverse_foreign_key) unless _association.forced_nil_inverse?
- 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 remove_indexes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_indexes(models = ::Mongoid.models)
models.each do |model|
next if model.embedded?
begin
model.remove_indexes
- 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_search_indexes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_search_indexes(models)
logger.info('MONGOID: Waiting for search indexes to be created')
logger.info('MONGOID: Press ctrl-c to skip the wait and let the indexes be created in the background')
models.each do |model, names|
- 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 text_search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def text_search(terms, opts = nil)
if terms.nil?
raise Errors::CriteriaArgumentRequired, :terms
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 build
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build(base, object, _type = nil, selected_fields = nil)
if object.is_a?(Hash)
if _loading? && base.persisted?
Factory.execute_from_db(klass, object, nil, selected_fields, execute_callbacks: false)
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 __mongoize_fk__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __mongoize_fk__(association, object)
if object.resizable?
object.blank? ? object : association.convert_to_foreign_key(object)
else
object.blank? ? [] : association.convert_to_foreign_key(Array(object))
- 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 apply_default
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def apply_default(name)
unless attributes.key?(name)
if field = fields[name]
default = field.eval_default(self)
unless default.nil? || field.lazy?
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def create!(attributes = nil, type = nil, &block)
if attributes.is_a?(::Array)
attributes.map { |attrs| create!(attrs, type, &block) }
else
doc = build(attributes, type, &block)
- 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 set_min
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_min(fields)
prepare_atomic_operation do |ops|
process_atomic_operations(fields) do |field, value|
current_value = attributes[field]
if value < current_value
- 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 discriminator_key=
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def discriminator_key=(value)
raise Errors::InvalidDiscriminatorKeyTarget.new(self, superclass) if hereditary?
_mongoid_clear_types
- 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 _gather_touch_updates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _gather_touch_updates(now, field = nil)
return if touch_callbacks_suppressed?
field = database_field_name(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 __evolve_range__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __evolve_range__(serializer: nil)
__evolve_range_naive__.transform_values! do |value|
if serializer
serializer.evolve(value)
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"