Showing 13 of 15 total issues
Method update_index
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def update_index(object)
if model.index_defined?
indexes = model.indexes.each_with_object([]) {|name, obj|
next if name == :id || object.public_send("#{name}_changed?")
- 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
Class Base
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
include ActiveModel::Model
include Associations
include Schema
include Inspection
Method find_by
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def find_by(conditions)
if conditions.is_a?(Hash)
conditions.symbolize_keys!
if index = conditions.keys.detect {|key| key.in?(indexes) }
value = conditions.delete(index)
- 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 belongs_to
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def belongs_to(*args)
name, options = Utils.parse_args(args)
model = Utils.model_for(name, safe: true, **options)
if model && model < Findable::Base
- 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 import
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def import(hashes)
lock do
indexes = Hash.new {|h, k| h[k] = [] }
values = hashes.each_with_object([]) do |hash, obj|
hash = hash.with_indifferent_access
- 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 try_lock!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def try_lock!(start)
loop do
break if redis.setnx(@lock_key, expiration)
current = redis.get(@lock_key).to_f
- 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 delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def delete(object)
if model.index_defined?
model.indexes.each do |name|
next if name == :id
if value = object.public_send("#{name}_was") || object.public_send(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 where
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def where(conditions)
conditions.symbolize_keys!
if index = conditions.keys.detect {|key| key.in?(indexes) }
value = conditions.delete(index)
if index == :id
- 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 target_files
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def target_files(seed_dir: nil, seed_files: nil)
target_dir = pathname(seed_dir || Findable.config.seed_dir)
raise UnknownSeedDir.new(target_dir) unless target_dir.try(:exist?)
seed_files = seed_files.map!(&:to_s) if seed_files
- 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 model_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.model_for(name, options = {})
unless model_name = options[:class_name].presence
name = options[:collection] ? name.to_s.singularize : name.to_s
model_name = name.camelize
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 belongs_to
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def belongs_to(*args)
name, options = Utils.parse_args(args)
model = Utils.model_for(name, safe: true, **options)
foreign_key = options[:foreign_key].presence || name.to_s.foreign_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 deserialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(raw_data, klass = nil)
objects = Array(raw_data).compact.map {|data|
object = @serializer.load(data)
object = object.with_indifferent_access if object.is_a?(Hash)
klass ? klass.new(object) : object
- 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 find
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find(ids)
if ids.is_a?(Array)
if refined = records.select {|record| record.id.in?(ids) }
regenerate(refined)
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"