Showing 236 of 236 total issues
Class Mongo
has 62 methods (exceeds 20 allowed). Consider refactoring. Open
class Mongo
extend Forwardable
include Enumerable
include Aggregable::Mongo
include Atomic
Method _mongoid_expand_keys
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
private def _mongoid_expand_keys(expr)
unless expr.is_a?(Hash)
raise ArgumentError, 'Argument must be a Hash'
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
Class Memory
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class Memory
include Enumerable
include Aggregable::Memory
include Association::EagerLoadable
include Queryable
Method define_callbacks!
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def self.define_callbacks!(association)
name = association.name
cache_column = association.counter_cache_column_name.to_sym
association.inverse_class.tap do |klass|
- 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 45 (exceeds 5 allowed). Consider refactoring. Open
module_function def matches?(exists, value, condition)
if condition.is_a?(Hash)
condition.all? do |k, cond_v|
k = k.to_s
if k.start_with?('$')
- 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
File mongo.rb
has 409 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mongoid/atomic_update_preparer'
require "mongoid/contextual/mongo/documents_loader"
require "mongoid/contextual/atomic"
require "mongoid/contextual/aggregable/mongo"
require "mongoid/contextual/command"
File selectable.rb
has 403 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongoid
class Criteria
module Queryable
# An queryable selectable is selectable, in that it has the ability to select
File fields.rb
has 372 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "mongoid/fields/standard"
require "mongoid/fields/encrypted"
require "mongoid/fields/foreign_key"
require "mongoid/fields/localized"
require "mongoid/fields/validators"
Method shard_collections
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def shard_collections(models = ::Mongoid.models)
models.map do |model|
next if model.shard_config.nil?
if model.embedded? && !model.cyclic?
- 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 a Cognitive Complexity of 31 (exceeds 5 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.
- 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 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
module Queryable
# An queryable selectable is selectable, in that it has the ability to select
# document from the database. The selectable module brings all functionality
Class Criteria
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
include Enumerable
# @api private
alias :_enumerable_find :find
Class Proxy
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Proxy < Association::Many
extend Forwardable
# class-level methods for HasMany::Proxy
module ClassMethods
Class Enumerable
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Enumerable
extend Forwardable
include ::Enumerable
# The three main instance variables are collections of documents.
Method set
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def set(setters)
prepare_atomic_operation do |ops|
process_atomic_operations(setters) do |field, value|
field_seq = field.to_s.split('.')
- 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 None
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class None
include Enumerable
include Aggregable::None
include Queryable
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")
Method traverse_association_tree
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def traverse_association_tree(key, fields, associations, aliased_associations)
klass = nil
field = nil
key.split('.').each_with_index do |meth, i|
fs = i == 0 ? fields : klass&.fields
- 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_value_at_path
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_value_at_path(document, field_path)
return if field_path.blank? || !document
segment, remaining = field_path.to_s.split('.', 2)
curr = if document.is_a?(Document)
- 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
File memory.rb
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "mongoid/contextual/aggregable/memory"
require "mongoid/association/eager_loadable"
module Mongoid
module Contextual