Showing 5 of 5 total issues
Method setup_validators
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def setup_validators(attribute_name, klass, options)
return if skip_validators?(attribute_name, options) || !include_attribute?(attribute_name, options)
klass.validators.each do |validator|
if validator.attributes.include?(attribute_name.to_sym)
validator_class = validator.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 get_active_record_attributes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_active_record_attributes(klass, options)
attributes = []
attribute_names = get_attribute_names(klass.attribute_names.dup, options)
attribute_names.each do |attribute_name|
if include_attribute?(attribute_name, 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 translate_primitive
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def translate_primitive(primitive)
return nil unless primitive
translated_primitive = primitive.to_s.capitalize
translated_primitive = Virtus::Attribute::Boolean if translated_primitive == 'Boolean'
translated_primitive = DateTime if translated_primitive == 'Datetime'
- 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 include_attribute?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def include_attribute?(attribute_name, options)
# Attributes we don't want to inherit
exclude_attributes = ['id']
exclude_attributes << ['created_at', 'updated_at'] unless options[:include_timestamps]
exclude_attributes << options[:exclude] if options[:exclude]
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if !@model
raise ArgumentError, 'Missing required argument "model"'
else
record_orig, attribute_orig = record, attribute
- 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"