Showing 91 of 169 total issues
Method current_site_url
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def current_site_url
if current_site.domains.blank?
preview_url(current_site)
else
protocol = current_site.redirect_to_https? ? 'https' : 'http'
- 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 set_slug
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_slug
self._slug = self._label.dup if self._slug.blank? && self._label.present?
if self._slug.present?
# we can't rely on the self.site property yet (brand new entry for instance)
- 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 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 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 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
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 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 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
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 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 _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 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 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 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 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 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) {
Function updateSectionText
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function updateSectionText(_window, section, blockId, settingId, value) {
Method create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create(email_or_account)
_account = if email_or_account.respond_to?(:email)
email_or_account
else
Locomotive::Account.find_by_email(email_or_account)
- 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"