Method update_or_destroy_records!
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def update_or_destroy_records!(records_batch_iterator, inventory_objects_index, attributes_index, all_attribute_keys)
hashes_for_update = []
records_for_destroy = []
indexed_inventory_objects = {}
- Read upRead up
- Create a ticketCreate a ticket
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_records!
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def create_records!(all_attribute_keys, batch, attributes_index, on_conflict: nil)
indexed_inventory_objects = {}
hashes = []
create_time = time_now
batch.each do |index, inventory_object|
- Read upRead up
- Create a ticketCreate a ticket
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 map_ids_to_inventory_objects
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def map_ids_to_inventory_objects(indexed_inventory_objects, all_attribute_keys, hashes, result, on_conflict:)
if on_conflict == :do_nothing
# TODO(lsmola) is the comment below still accurate? We will update some partial rows, the actual skeletal
# precreate will still do nothing.
# For ON CONFLICT DO NOTHING, we need to always fetch the records plus the attribute_references. This path
- Read upRead up
- Create a ticketCreate a ticket
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 concurrent_safe_batch.rb
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "inventory_refresh/save_collection/saver/base"
require "inventory_refresh/save_collection/saver/partial_upsert_helper"
require "inventory_refresh/save_collection/saver/retention_helper"
require "active_support/core_ext/module/delegation"
- Create a ticketCreate a ticket
Cyclomatic complexity for create_records! is too high. [19/11] Open
def create_records!(all_attribute_keys, batch, attributes_index, on_conflict: nil)
indexed_inventory_objects = {}
hashes = []
create_time = time_now
batch.each do |index, inventory_object|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method update_or_destroy_records!
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_or_destroy_records!(records_batch_iterator, inventory_objects_index, attributes_index, all_attribute_keys)
hashes_for_update = []
records_for_destroy = []
indexed_inventory_objects = {}
- Create a ticketCreate a ticket
Cyclomatic complexity for update_or_destroy_records! is too high. [17/11] Open
def update_or_destroy_records!(records_batch_iterator, inventory_objects_index, attributes_index, all_attribute_keys)
hashes_for_update = []
records_for_destroy = []
indexed_inventory_objects = {}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Cyclomatic complexity for map_ids_to_inventory_objects is too high. [17/11] Open
def map_ids_to_inventory_objects(indexed_inventory_objects, all_attribute_keys, hashes, result, on_conflict:)
if on_conflict == :do_nothing
# TODO(lsmola) is the comment below still accurate? We will update some partial rows, the actual skeletal
# precreate will still do nothing.
# For ON CONFLICT DO NOTHING, we need to always fetch the records plus the attribute_references. This path
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method save!
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def save!(association)
attributes_index = {}
inventory_objects_index = {}
all_attribute_keys = Set.new + inventory_collection.batch_extra_attributes
- Read upRead up
- Create a ticketCreate a ticket
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_records!
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_records!(all_attribute_keys, batch, attributes_index, on_conflict: nil)
indexed_inventory_objects = {}
hashes = []
create_time = time_now
batch.each do |index, inventory_object|
- Create a ticketCreate a ticket
Method save!
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save!(association)
attributes_index = {}
inventory_objects_index = {}
all_attribute_keys = Set.new + inventory_collection.batch_extra_attributes
- Create a ticketCreate a ticket
Method map_ids_to_inventory_objects
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_ids_to_inventory_objects(indexed_inventory_objects, all_attribute_keys, hashes, result, on_conflict:)
if on_conflict == :do_nothing
# TODO(lsmola) is the comment below still accurate? We will update some partial rows, the actual skeletal
# precreate will still do nothing.
# For ON CONFLICT DO NOTHING, we need to always fetch the records plus the attribute_references. This path
- Create a ticketCreate a ticket
Method batch_iterator
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def batch_iterator(association)
if pure_sql_records_fetching
# Building fast iterator doing pure SQL query and therefore avoiding redundant creation of AR objects. The
# iterator responds to find_in_batches, so it acts like the AR relation. For targeted refresh, the association
# can already be ApplicationRecordIterator, so we will skip that.
- Read upRead up
- Create a ticketCreate a ticket
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"