Showing 91 of 169 total issues
Method build_fullpath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build_fullpath
if self.index_or_not_found?
self.site.each_locale { |locale, current| self.fullpath = self.slug }
else
_parent = self.parent # do not hit the database more than once
- 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 render_exception
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def render_exception(exception)
::Locomotive.log "[ApplicationError] #{exception.inspect}"
status = (case exception
when ::Mongoid::Errors::DocumentNotFound then 404
- 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 underscore_keys
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def underscore_keys
new_hash = {}
self.each_pair do |key, value|
if value.respond_to?(:collect!) # 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 fetch_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_file(source)
file = nil
if source.is_a?(String) || source.is_a?(Hash) # simple string or drop
source = source['url'] if source.is_a?(Hash)
- 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 render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { pageId, iframeLoaded, location } = this.props;
const currentKey = iframeLoaded ? location.pathname : 'startup';
const slideDirection = !iframeLoaded ? 'up' : (location.state || {}).slideDirection || 'up';
const timeout = slideDirection === 'none' ? { enter: 1, exit: 1 } : { enter: 150, exit: 100 };
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { sectionDefinition } = this.props;
return (
<div className="editor-section-blocks--new" ref={el => this.pickerRef = el}>
Function render
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { setting, getValue, label, handleChange } = this.props;
const value = getValue(null);
const asset = value && typeof(value) === 'object' ? value : { url: value };
Method _metafields_schema_schema
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _metafields_schema_schema
{
'id' => 'http://locomotive.works/schemas/metafields.json',
'definitions' => {
'field' => {
Method to_json
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_json
add_authenticated_header
if get?
add_pagination_header if resource.respond_to?(:total_pages)
Method as_json
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def as_json(methods = nil)
methods ||= self.getters
{}.tap do |hash|
methods.each do |meth|
_options = self.property_options[meth]
- 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 build
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const build = (pageId, contentEntryId, baseUrl) => {
const _pageId = compact([pageId, contentEntryId]).join('-');
const basePath = `/${_pageId}/content/edit`;
const sectionsPath = `${basePath}/sections`;
- 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 attributes=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def attributes=(values)
return unless values
@_attributes = values # memoize them for the callbacks
- 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 document_stamp
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def document_stamp(document)
distance = distance_of_time_in_words_to_now(document.updated_at)
update = document.updated_at && document.updated_at != document.created_at
if account = (document.updated_by || document.created_by)
- 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 render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const TabPane = {
sections: Sections,
settings: Settings,
seo: Seo
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { input, suggestions, loading } = this.state;
const inputProps = {
placeholder: this.props.placeholder,
value: input || '',
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { input, suggestions, loading } = this.state;
const inputProps = {
placeholder: this.props.placeholder,
value: input || '',
Method update_all
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_all(attributes)
each_metafield(attributes) do |namespace, name, value|
next unless field = site.find_metafield(name)
if field['localized']
- 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 to_json
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_json
add_authenticated_header
if get?
add_pagination_header if resource.respond_to?(:total_pages)
- 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 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"