Showing 197 of 236 total issues
Method add_atomic_changes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_atomic_changes(document, name, key, mods, new, old)
Method evolve
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def evolve(object)
if object_id_field? || object.is_a?(Document)
if association.polymorphic?
association.convert_to_foreign_key(object)
elsif object.is_a?(Document) && object.respond_to?(association.primary_key)
- 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 one_matches?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module_function def one_matches?(exists, value, condition)
case condition
when 1
# Double
Float === 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 preload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def preload(associations, docs)
assoc_map = associations.group_by(&:inverse_class_name)
docs_map = {}
queue = [ klass.to_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 process_attributes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_attributes(attrs = nil)
attrs ||= {}
unless attrs.empty?
attrs = sanitize_for_mass_assignment(attrs)
attrs.each_pair do |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 setters
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def setters
mods = {}
changes.each_pair do |name, changes|
next unless changes
- 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_ids_for_find
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def prepare_ids_for_find(args)
args.flat_map do |arg|
case arg
when Array, Set
prepare_ids_for_find(arg)
- 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_run_child_before_callbacks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _mongoid_run_child_before_callbacks(kind, children: [], callback_list: [])
children.each do |child|
chain = child.__callbacks[child_callback_type(kind, child)]
env = ActiveSupport::Callbacks::Filters::Environment.new(child, false, nil)
next_sequence = compile_callbacks(chain)
- 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 properties_for_fields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def properties_for_fields(model)
model.fields.each_with_object({}) do |(name, field), props|
next unless field.is_a?(Mongoid::Fields::Encrypted)
props[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 documents_for_iteration
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def documents_for_iteration
if @documents_loader
if @documents_loader.started?
@documents_loader.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"
Further reading
Consider simplifying this complex logical expression. Open
if v.is_a?(Hash) &&
v.length == 1 &&
(new_k = v.keys.first).start_with?('$') &&
(existing_kv = c.selector[k]).is_a?(Hash) &&
!existing_kv.key?(new_k) &&
Method add_key
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_key(name, strategy, operator, additional = nil, &block)
Method key
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def key(name, strategy, operator, additional = nil, &block)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(name, strategy, operator, expanded = nil, &block)
Method build_auto_encryption_options
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_auto_encryption_options(opts, database)
return nil unless opts[:auto_encryption_options]
opts[:auto_encryption_options].dup.tap do |auto_encryption_options|
if auto_encryption_options.key?(:schema_map)
- 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_relation_touch_method
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def define_relation_touch_method(name, association)
relation_classes = if association.polymorphic?
association.send(:inverse_association_classes)
else
[ association.relation_class ]
- 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 inverse_foreign_key
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def inverse_foreign_key
if @options.key?(:inverse_foreign_key)
@options[:inverse_foreign_key]
elsif @options.key?(:inverse_of)
inverse_of ? "#{inverse_of.to_s.singularize}#{FOREIGN_KEY_SUFFIX}" : 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 selection
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def selection(criterion = nil)
clone.tap do |query|
if criterion
criterion.each_pair do |field, value|
yield(query.selector, field.is_a?(Key) ? field : field.to_s, 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 substitute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def substitute(replacement)
return self if replacement == self
if _assigning?
_base.add_atomic_unset(_target) unless replacement
- 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 check_for_id_violation!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_for_id_violation!
# look for the basic criteria of an update (see #update?)
return unless existing&.persisted? && !destroyable?
# if the id is either absent, or if it equals the existing record'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"