Showing 91 of 169 total issues
Method create_api_token
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_api_token(email, password, api_key)
if api_key.present?
account = self.where(api_key: api_key).first
raise 'The API key is invalid.' if account.nil?
- 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 persist_missing_translations
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def persist_missing_translations(site, translations)
new_translations = []
translations.each do |attributes|
if existing = site.translations.where(key: attributes[:key]).first
- 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_from_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def value_from_type(type, value, options)
case type
when :file
value.blank? ? '' : value.guess_url(options[:host])
when :belongs_to
- 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 class_names
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def class_names
base = ['page']
base << (children? ? 'node' : 'leaf')
base << (published? ? 'published' : 'unpublished')
base << (index_or_not_found? ? 'fixed' : '') if children?
- 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 load_page
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def load_page
page_id, content_entry_id = params[:page_id].split('-')
content_entry_id ||= params[:content_entry_id]
@page = current_site.pages.find(page_id).tap do |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"
Further reading
Function buildItems
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const buildItems = props => {
return (props.sectionContent.blocks || []).map(block => {
const definition = props.sectionDefinition.blocks.find(def => def.type === block.type)
if (definition === null || definition === undefined) return null;
- 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_section_attributes!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_section_attributes!(page, parsed)
[:top, :bottom].each do |placement|
parsed[:sections][placement] = parsed[:sections][placement].map do |(_page, block, attributes)|
# we don't want hidden sections
next unless is_element_visible?(page, parsed, _page, block)
- 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 import_row
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def import_row(row, index, entry)
is_new_entry = !entry.persisted?
entry.attributes = attributes_from_row(row)
if entry.save
- 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 block_visible?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def block_visible?(page_id, parsed, attributes)
block_name = attributes[:block]
descendant = parsed[:extends][page_id]
return true if descendant.nil?
- 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 domains_must_not_be_reserved
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def domains_must_not_be_reserved
return if self.domains.empty? || Locomotive.config.reserved_domains.blank?
self.domains.each do |domain|
any = Locomotive.config.reserved_domains.any? do |matcher|
- 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
Function pokeSection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const pokeSection = (_window, action, sectionId, blockId) => {
return new Promise((resolve, reject) => {
var $elem, eventName, eventData;
if (!_window) {
- 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 ensure_class_name_security
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ensure_class_name_security(field)
if field.class_name =~ /^Locomotive::ContentEntry([a-z0-9]+)$/
# if the content type does not exist (anymore), bypass the security checking
content_type = Locomotive::ContentType.find($1) rescue nil
- 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 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 selection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def selection(criterion = nil)
clone.tap do |query|
if criterion
criterion.each_pair do |field, value|
_field = field.is_a?(Key) || field.is_a?(Origin::Key) ? field : field.to_s
- 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
Function arrayMove
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function arrayMove(array, oldIndex, newIndex) {
var newArray = [];
if (oldIndex === newIndex) return array;
- 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_tree
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _build_tree(current_page, pages)
i, children = 0, []
while !pages.empty?
page = pages[i]
- 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
Function updateSectionText
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function updateSectionText(_window, section, blockId, settingId, value) {
Function updateSectionInput
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function updateSectionInput(section, blockId, fieldType, id, newValue) {
Function searchForResources
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function searchForResources(url, locale, type, q, scope) {
Method bubble_fields_errors_up
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def bubble_fields_errors_up
return if self.errors[:entries_custom_fields].empty?
self.entries_custom_fields.each do |field|
next if field.errors.blank?
- 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"