Showing 197 of 236 total issues
Method database_field_name
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def database_field_name(name, relations, aliased_fields, aliased_associations)
return nil unless name.present?
key = name.to_s
segment, remaining = key.split('.', 2)
- 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_add_top_level_operation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private def _mongoid_add_top_level_operation(operator, criteria)
# Flatten the criteria. The idea is that predicates in MongoDB
# are always hashes and are never arrays. This method additionally
# allows Criteria instances as predicates.
# The flattening is existing Mongoid behavior but we could possibly
- 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_client
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_client(configuration)
raise Errors::NoClientsConfig.new unless configuration
config = configuration.dup
uri = config.delete(:uri)
database = config.delete(:database) || Mongo::URI.get(uri).database
- 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_each
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(document, attribute, value)
field = document.fields[document.database_field_name(attribute)]
if field.try(:localized?) && !value.blank?
value.each_pair do |_locale, _value|
document.errors.add(
- 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 __multi__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __multi__(criteria, operator)
clone.tap do |query|
sel = query.selector
criteria.flatten.each do |expr|
next unless expr
- 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 shard_key
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def shard_key(*args)
unless args.first.is_a?(Hash)
# Shorthand syntax
if args.last.is_a?(Hash)
raise ArgumentError, 'Shorthand shard_key syntax does not permit 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 upsert
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def upsert(options = {})
prepare_upsert(options) do
if options[:replace]
if options[:set_on_insert]
raise ArgumentError, "cannot specify :set_on_insert with `replace: true`"
- 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_remove
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def pre_process_batch_remove(docs, method)
docs.map do |doc|
self.path = doc.atomic_path unless path
execute_callback :before_remove, doc
unless _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"
Further reading
Method resolve_name
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def resolve_name(mod, name)
cls = exc = nil
parts = name.to_s.split('::')
if parts.first == ''
parts.shift
- 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_to_set
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_to_set(adds)
prepare_atomic_operation do |ops|
process_atomic_operations(adds) do |field, value|
existing = send(field) || attributes[field]
if existing.nil?
- 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_multi
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def evolve_multi(specs)
unless specs.is_a?(Array)
raise ArgumentError, "specs is not an array: #{specs.inspect}"
end
specs.map do |spec|
- 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_spec
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_spec(klass, spec, options)
raise Errors::InvalidIndex.new(klass, spec, options) if !spec.is_a?(::Hash)
spec.each_pair do |name, value|
next if name == :options
unless VALID_TYPES.include?(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 create_document
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_document(method, attrs = nil, &block)
attrs = (create_attrs || {}).merge(attrs || {})
attributes = selector.reduce(attrs) do |hash, (key, value)|
unless invalid_key?(hash, key) || invalid_embedded_doc?(value)
hash[key] = 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 add_field_expression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_field_expression(field, value)
unless field.is_a?(String)
raise ArgumentError, "Field must be a string: #{field}"
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 remove_indexes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def remove_indexes
indexed_database_names.each do |database|
with(database: database) do |klass|
begin
klass.collection.indexes(session: _session).each do |spec|
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_atomic_changes(document, name, key, mods, new_elements, old_elements)
Avoid deeply nested control flow statements. Open
if options = condition['$options']
cond_v = case cond_v
when Regexp
BSON::Regexp::Raw.new(cond_v.source, options)
when BSON::Regexp::Raw
Method delete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete(document)
execute_callbacks_around(:remove, document) do
result = _target.delete(document) do |doc|
if doc
unbind_one(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 collect_descendants
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def collect_descendants
children = []
to_expand = _children
expanded = {}
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def prepare(field, operator, value)
unless operator =~ /exists|type|size/
value = value.__expand_complex__
field = field.to_s
name = aliases[field] || 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"