Method method_missing
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(name, *args)
if name.to_s[-1,1] == "="
name = name.to_s.chop.to_sym
_set_attribute(name, args.first)
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"
Further reading
Class BaseWithoutValidation
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class BaseWithoutValidation
include Mapping
include Configuration
include Callbacks
include Caching
Method method_missing
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def method_missing(name, *args)
if name.to_s[-1,1] == "="
name = name.to_s.chop.to_sym
_set_attribute(name, args.first)
else
Method inspect
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def inspect
inspection = if @attributes.any?
@attributes.collect { |key, value|
"#{key}: #{value_for_inspect(value)}"
}.compact.join(", ")
- 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
Avoid deeply nested control flow statements. Open
raise ValidationFailedException.new if respond_to?(:valid?) && !valid?
Method value_for_inspect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def value_for_inspect(value)
if value.is_a?(String) && value.length > 50
"#{value[0..50]}...".inspect
elsif value.is_a?(Date) || value.is_a?(Time)
%("#{value.respond_to?(:to_fs) ? value.to_fs(:db) : value.to_s(:db)}")
- 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_attribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _set_attribute(key, value)
old_value = @dirty_attributes[key.to_sym]
old_value = @attributes[key.to_sym] unless old_value
old_value = old_value[0] if old_value and old_value.is_a? Array
@dirty_attributes[key.to_sym] = [old_value, value] if old_value != 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"