lib/inventory_refresh/inventory_collection.rb
Class InventoryCollection
has 46 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class InventoryCollection
# @return [Boolean] A true value marks that we collected all the data of the InventoryCollection,
# meaning we also collected all the references.
attr_accessor :data_collection_finalized
- Create a ticketCreate a ticket
File inventory_collection.rb
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require "inventory_refresh/inventory_collection/builder"
require "inventory_refresh/inventory_collection/data_storage"
require "inventory_refresh/inventory_collection/index/proxy"
require "inventory_refresh/inventory_collection/reference"
require "inventory_refresh/inventory_collection/references_storage"
- Create a ticketCreate a ticket
Method initialize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(properties = {})
init_basic_properties(properties[:association],
properties[:model_class],
properties[:name],
properties[:parent])
- Create a ticketCreate a ticket
Method db_collection_for_comparison
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def db_collection_for_comparison
if targeted?
if targeted_arel.respond_to?(:call)
targeted_arel.call(self)
elsif parent_inventory_collections.present?
- 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
Use filter_map
instead. Open
Open
:resource_counter].collect do |col|
col if supports_column?(col)
end.compact
- Create a ticketCreate a ticket
- Exclude checks
Use filter_map
instead. Open
Open
@internal_timestamp_columns = %i[created_at created_on updated_at updated_on].collect do |timestamp_col|
timestamp_col if supports_column?(timestamp_col)
end.compact
- Create a ticketCreate a ticket
- Exclude checks