Showing 5 of 5 total issues
Method validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate record
(is_active_record_4? ? attributes : attributes.first).each do |locale, attribute|
value = record.read_attribute_for_validation :"#{attribute}_#{locale}"
next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank])
validate_each record, attribute, locale, 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 build_relation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def build_relation klass, table, attribute, locale, value #:nodoc:
column = klass.columns_hash[attribute.to_s]
value = build_yaml_dump_value klass, value, column, locale
if !options[:case_sensitive] && value && column.text?
- 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 build_relation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_relation klass, table, attribute, locale, value #:nodoc:
Method add_uniqueness_validation_error
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_uniqueness_validation_error record, options, attribute, locale, value #:nodoc:
Method validate_each
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
@validators = {}
record.available_locales.each do |locale|
validations = active_record_validations_array
validations.each do |validation|
- 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"