Method localize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def localize(new_locales, previous_default_locale)
default_locale = previous_default_locale || content_type.site.default_locale
content_type.entries.each_by(50) do |entry|
slug = entry._slug_translations[default_locale]
- 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 sanitize_attributes!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_attributes!(attributes)
# needed to get the custom fields
_entry = content_type.entries.build
# if the user deletes all the entries of a many_to_many field,
- 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 prepare_options_for_all
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def prepare_options_for_all(options)
{ where: prepare_where_statement(options) }.tap do |_options|
unless options[:no_pagination]
_options[:page] = options[:page] || 1
_options[:per_page] = options[:per_page] || Locomotive.config.ui[:per_page]
- 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"