Showing 89 of 89 total issues
Method apply_metafields_samples
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def apply_metafields_samples(entity)
entity.metafields_schema&.each do |namespace|
namespace[:fields].each do |field|
next unless field[:sample].present?
- 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 extract_locale
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_locale
# Regarding the index page (basically, "/"), we've to see if we could
# guess the locale from the headers the browser sends to us.
locale = if is_index_page? && !site.bypass_browser_locale
locale_from_params || locale_from_cookie || locale_from_header
- 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 redirect_url
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def redirect_url
if apply_redirection?
if site.prefix_default_locale
path_with_locale if locale_not_mentioned_in_path?
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
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(repository_klass, scope, adapter, options = {}, &block)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(message, template_name, source, line_number, original_backtrace)
Method association
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def association(type, name, repository_klass, options = nil, &block)
Method safe_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def safe_value(value, type = 'string')
case type
when 'boolean'
['1', 'true', true].include?(value) ? true : false
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
Method prepare_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def prepare_attributes(content_type, attributes)
select_field_names = content_type.fields.selects.map(&:name)
attributes.each do |key, value|
next unless value.is_a?(String)
- 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 parse_snippet_template
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_snippet_template(template_name)
source = if template_name.include?('{{')
template_name
else
snippet = services.snippet_finder.find(template_name)
- 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 each_file
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def each_file(&block)
Dir.glob(File.join(path, '**', '*')).each do |filepath|
next unless is_liquid_file?(filepath)
relative_path = get_relative_path(filepath)
- 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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse(tokens)
# look for editable elements (only used by the Engine)
# In the next version of Locomotive (v5), we won't support the editable elements
# NOTE: it doesn't support dynamically choosen template
template_name = template_name_expr.respond_to?(:name) ? template_name_expr.name : template_name_expr
- 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 value_to_id
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def value_to_id(value, target_id)
return values_to_ids(value, target_id) if value.kind_of?(Array)
_value = if value.is_a?(Hash)
value['_id'] || value[:_id]
- 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 find_dynamic_url_redirection
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_dynamic_url_redirection(redirections_hash)
number_of_segments = requested_url.split('/').size
# attempt to find the first dynamic route which matches
redirections_hash.each do |route, redirection|
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def translate(input, options = {})
locale = options['locale'] || self.current_locale
scope = options.delete('scope')
key = scope.present? ? "#{scope.gsub('.', '_')}_#{input}" : input
- 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 fetch_page
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fetch_page
page = site.routes.present? ? fetch_page_from_routes : nil
# if we don't find it from the site routes, try with the paths
page ||= fetch_page_from_paths
- 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 find_page
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_page(type, value)
case type
when 'page'
page_finder.find_by_id(value)
when 'content_entry'
- 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 _call
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _call
if cacheable?
key = cache_key
# TODO: only for debugging
- 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 value_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def value_for(entry, name, conditions = {})
return nil if entry.nil?
if field = content_type.fields_by_name[name]
value = entry.send(name)
- 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 order_by
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def order_by
if (order_by = self[:order_by]).present?
# from Filesystem -> string, from MongoDB -> array (string transformed by Engine)
name, direction = order_by.respond_to?(:each) ? order_by : order_by.split
{ name.to_sym => direction || 'asc' }
- 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_parts
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _build_parts(pagination, path, page, hellip_break)
if pagination['current_page'] == page
pagination['parts'] << no_link(page)
elsif is_page_a_bound?(pagination, page)
pagination['parts'] << link(page, page, path)
- 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"