Showing 92 of 92 total issues
Class Metadata
has 81 methods (exceeds 20 allowed). Consider refactoring. Open
class Metadata < Hash
delegate :foreign_key_default, :stores_foreign_key?, to: :relation
# Returns the as option of the relation.
Class Many
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Many < Relations::Many
delegate :count, to: :criteria
delegate :first, :in_memory, :last, :reset, :uniq, to: :target
Method autosave
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def autosave(metadata)
if metadata.autosave? && !metadata.embedded?
save_method = :"autosave_documents_for_#{metadata.name}"
define_method(save_method) 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
Class Many
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class Many < Relations::Many
include Batchable
# Appends a document or array of documents to the relation. Will set
# the parent and update the index in the process.
Class Criteria
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
include Enumerable
include Contextual
include Origin::Queryable
include Findable
Class Mongo
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class Mongo
include Enumerable
include Aggregable::Mongo
include Atomic
include Relations::Eager
File metadata.rb
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongoid
module Relations
# The "Grand Poobah" of information about any relation is this class. It
# contains everything you could ever possible want to know.
File profile.rb
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "perftools"
require "mongoid"
require "./perf/models"
Mongoid.connect_to("mongoid_perf_test")
Class Enumerable
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Enumerable
include ::Enumerable
# The three main instance variables are collections of documents.
#
Class Memory
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Memory
include Enumerable
include Aggregable::Memory
include Relations::Eager
include Queryable
File many.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongoid
module Relations
module Referenced
# This class defines the behaviour for all relations that are a
Class ManyToMany
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class ManyToMany < Many
# Appends a document or array of documents to the relation. Will set
# the parent and update the index in the process.
#
File benchmark.rb
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "benchmark"
require "mongoid"
require "./perf/models"
Mongoid.connect_to("mongoid_perf_test")
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, metadata|
next unless metadata.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
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
Class Modifiers
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Modifiers < Hash
# Add the atomic $addToSet modifiers to the hash.
#
# @example Add the $addToSet modifiers.
File fields.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "mongoid/fields/standard"
require "mongoid/fields/foreign_key"
require "mongoid/fields/localized"
require "mongoid/fields/validators"
Method add_counter_cache_callbacks
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def add_counter_cache_callbacks(meta)
name = meta.name
cache_column = meta.counter_cache_column_name.to_sym
after_create 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 substitute
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def substitute(replacement)
if replacement != self
if _assigning?
base.add_atomic_unset(target) unless replacement
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 pre_process_batch_insert
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def pre_process_batch_insert(docs)
docs.map do |doc|
next unless doc
append(doc)
if persistable? && !_assigning?
- 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"