Showing 197 of 236 total issues
Class HasAndBelongsToMany
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class HasAndBelongsToMany
include Relatable
include Buildable
# The options available for this type of association, in addition to the
File benchmark.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "benchmark"
require "mongoid"
require "./perf/models"
Mongoid.connect_to("mongoid_perf_test")
Class HasMany
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class HasMany
include Relatable
include Buildable
# The options available for this type of association, in addition to the
Method cascadable_children
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def cascadable_children(kind, children = Set.new)
embedded_relations.each_pair do |name, association|
next unless association.cascading_callbacks?
without_autobuild do
delayed_pulls = delayed_atomic_pulls[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
Class Modifiers
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Modifiers < Hash
# Add the atomic $addToSet modifiers to the hash.
#
# @example Add the $addToSet modifiers.
Method write_attribute
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def write_attribute(name, value)
validate_writable_field_name!(name.to_s)
field_name = database_field_name(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 process_localized_attributes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def process_localized_attributes(klass, attrs)
klass.localized_fields.keys.each do |name|
if value = attrs.delete(name)
attrs["#{name}_translations"] = value
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 not
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def not(*criteria)
if criteria.empty?
dup.tap { |query| query.negating = true }
else
criteria.compact.inject(self.clone) do |c, new_s|
- 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 undefined_indexes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def undefined_indexes(models = ::Mongoid.models)
undefined_by_model = {}
models.each do |model|
unless model.embedded?
- 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_value
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def extract_value(attrs, field_name)
i = 1
num_meths = field_name.count('.') + 1
curr = attrs.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
Class Criteria
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
module Queryable
# The optional module includes all behavior that has to do with extra
# options surrounding queries, like skip, limit, sorting, etc.
Method evolve
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def evolve(object)
__evolve__(object) do |obj|
return if obj.nil?
case obj
when ::BigDecimal
- 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 matches?
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
module_function def matches?(exists, value, condition)
unless Hash === condition
raise Errors::InvalidQuery, "$elemMatch requires a Hash operand: #{Errors::InvalidQuery.truncate_expr(condition)}"
end
if Array === value && !value.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 define_autosave!
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.define_autosave!(association)
association.inverse_class.tap do |klass|
save_method = :"autosave_documents_for_#{association.name}"
klass.send(:define_method, save_method) do
if before_callback_halted?
- 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_association
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def validate_association(document, attribute)
# grab the proxy from the instance variable directly; we don't want
# any loading logic to run; we just want to see if it's already
# been loaded.
proxy = document.ivar(attribute)
- 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
Class BelongsTo
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class BelongsTo
include Relatable
include Buildable
# The options available for this type of association, in addition to the
Method atomically
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def atomically(join_context: nil)
join_context = Mongoid.join_contexts if join_context.nil?
call_depth = @atomic_depth ||= 0
has_own_context = call_depth.zero? || !join_context
@atomic_updates_to_execute_stack ||= []
- 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 cleanse_localized_field_names
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def cleanse_localized_field_names(name)
name = database_field_name(name.to_s)
klass = self
[].tap do |res|
- 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_logical_operator_expression
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def add_logical_operator_expression(operator, op_expr)
unless operator.is_a?(String)
raise ArgumentError, "Operator must be a string: #{operator}"
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 _mongoid_expand_keys
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private def _mongoid_expand_keys(expr)
unless expr.is_a?(Hash)
raise ArgumentError, 'Argument must be a Hash'
end