Showing 10 of 10 total issues
Class Base
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Base < ActiveHash::Base
extend ActiveModel::Callbacks
extend ActiveRepository::Finders
extend ActiveRepository::Writers
include ActiveModel::Validations
Method create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create(attributes={})
attributes = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys)
object = self.new(attributes)
if object.present? && object.valid?
- 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 save
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save(force=false)
execute_callbacks(before_save_methods)
result = true
if self.class == persistence_class
- 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 serialize!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def serialize!(attributes)
unless attributes.nil?
attributes.each do |key, value|
key = "id" if key == "_id"
self.send("#{key}=", (value.dup rescue value))
- 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 validate_each
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
query = (record.id ? "id <> #{record.id}" : 'id is not null')
if(options[:scope])
value = record.send(options[:scope])
- 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_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_attributes(attributes)
attributes = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys)
klass = self.class
model_class = persistence_class
- 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 save
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def save(*args)
if self.valid?
record = self.class.find_by(id: self.id)
self.class.insert(self) if record.nil? && record != self
- 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 execute_callbacks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def execute_callbacks(callbacks)
Array(callbacks).each do |callback|
method = callback[:method]
options = callback[:options]
- 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 set_timestamps
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_timestamps
if self.errors.empty?
self.created_at = DateTime.now.utc if self.respond_to?(:created_at=) && self.created_at.nil?
self.updated_at = DateTime.now.utc if self.respond_to?(:updated_at=)
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 can_run?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def can_run?
return @can_run if @can_run
if_option = @options[:if].nil? ? true : @object.send(@options[:if])
unless_option = @options[:unless].nil? ? false : @object.send(@options[:unless])
- 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"