Showing 199 of 238 total issues
Method accepts_nested_attributes_for
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def accepts_nested_attributes_for(*args)
options = args.extract_options!.dup
options[:autosave] = true if options[:autosave].nil?
options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank
- 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_filter_selected_fields
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _mongoid_filter_selected_fields(assoc_key)
return nil unless __selected_fields
# If the list of fields was specified using #without instead of #only
# and the provided list does not include the association, any of its
- 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 _handle_callbacks_after_instantiation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _handle_callbacks_after_instantiation(execute_callbacks)
if execute_callbacks
apply_defaults
yield self if block_given?
run_callbacks(:find) unless _find_callbacks.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 extract_attribute
has 33 lines of code (exceeds 25 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.
Method add_atomic_changes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_atomic_changes(document, name, key, mods, new_elements, old_elements)
old = (old_elements || [])
new = (new_elements || [])
if new.length > old.length
if new.first(old.length) == old
- 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 mul
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def mul(factors)
prepare_atomic_operation do |ops|
process_atomic_operations(factors) do |field, value|
factor = value.is_a?(BigDecimal) ? value.to_f : value
current = attributes[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"
Further reading
Method inc
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def inc(increments)
prepare_atomic_operation do |ops|
process_atomic_operations(increments) do |field, value|
increment = value.is_a?(BigDecimal) ? value.to_f : value
current = attributes[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"
Further reading
Method create!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create!(attributes = nil, &block)
_creating do
if attributes.is_a?(::Array)
attributes.map { |attrs| create!(attrs, &block) }
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 demongoize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def demongoize(object)
return if object.blank?
time = if object.acts_like?(:time)
Mongoid::Config.use_utc? ? object : object.getlocal
elsif object.acts_like?(:date)
- 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_arguments
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def prepare_arguments(kms_provider_name, client_name)
client = (client_name || 'default').to_s
client_options = Mongoid.clients[client]
unless client_options.is_a?(Hash)
raise Errors::NoClientConfig.new(client)
- 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 any_of
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def any_of(*criteria)
criteria = _mongoid_flatten_arrays(criteria)
case criteria.length
when 0
clone
- 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 write_attribute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_attribute(name, value)
validate_writable_field_name!(name.to_s)
field_name = database_field_name(name)
Method create_collection
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_collection(force: false)
if collection_name.empty?
# This is most probably an anonymous class, we ignore them.
return
end
Method matches?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def matches?(exists, value, condition)
case value
when BSON::Binary
value = value.data.split('').map { |n| '%02x' % n.ord }.join.to_i(16)
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 batch_replace
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def batch_replace(docs)
if docs.blank?
if _assigning? && !empty?
_base.delayed_atomic_sets.delete(path)
clear_atomic_path_cache
- 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 batch_remove
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def batch_remove(docs, method = :delete)
# If the _id is nil, we cannot use $pull and delete by searching for
# the id. Therefore we have to use pullAll with the documents'
# attributes.
removals = pre_process_batch_remove(docs, method)
- 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 update_inverse_keys
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_inverse_keys(association)
if previous_changes.has_key?(association.foreign_key)
old, new = previous_changes[association.foreign_key]
adds, subs = new - (old || []), (old || []) - new
- 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 merge!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def merge!(other)
other.each_pair do |key, value|
if value.is_a?(Hash) && self[key.to_s].is_a?(Hash)
value = self[key.to_s].merge(value) do |_key, old_val, new_val|
case _key.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 define_setter!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.define_setter!(association)
name = association.name
association.inverse_class.tap do |klass|
klass.re_define_method("#{name}=") do |object|
without_autobuild 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 demongoize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def demongoize(object)
return if object.nil?
if object.is_a?(Hash)
hash = object.slice('min', 'max', 'exclude_end', :min, :max, :exclude_end)
unless hash.blank?
- 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"