Showing 8 of 10 total issues
Method define_callback_for_cleaning_cache
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def define_callback_for_cleaning_cache(class_name, column, foreign_key, with_id, on: nil)
return if @callbacks_defined
@callbacks_defined = true
clean = ->(id){ clean_at(with_id ? id : 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 exec_by
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def exec_by(attr, primary_key, service_klasses, method, data: nil)
bindings = [@model]
reflects = (attr.belongs_to? ? [] : [attr.reflect])
if @model and attr.association?
if attr.belongs_to? and method != :clean_cache # no need to load binding when just cleaning 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 query_association
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def query_association(binding, id)
return binding.association(@column).load_target if binding.is_a?(::ActiveRecord::Base)
id = @reflect.active_record.where(id: id).limit(1).pluck(foreign_key).first if foreign_key != 'id'
case
when collection? ; return id ? @reflect.klass.where(@reflect.foreign_key => id).to_a : []
- 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 cache_at
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def cache_at(column, query = nil, expire_by: nil, on: nil, foreign_key: nil, primary_key: nil)
attr = AttrModel.new(self, column, foreign_key: foreign_key, primary_key: primary_key)
return cache_belongs_to(attr) if attr.belongs_to?
loaded = false
- 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
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add(object, class_name, id, foreign_key, model)
Method get_without_cache
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_without_cache(binding, attr)
query = get_query(binding, attr)
return binding ? binding.instance_exec(@id, &query) : query.call(@id) if @id and query.parameters.size == 1
return binding ? binding.instance_exec(&query) : query.call
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 foreign_key
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def foreign_key(reverse: false)
return @foreign_key if @foreign_key
return if not association?
# key may be symbol if specify foreign_key in association options
return @reflect.chain.last.foreign_key.to_s if reverse and join_table
- 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 new_constants_in
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def new_constants_in(*)
new_constants = super.each do |const_name|
hooks = load_hooks[const_name]
need_compact = false
hooks.each_with_index do |hook, idx|
- 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"