locomotivecms/engine

View on GitHub

Showing 91 of 169 total issues

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
Severity: Minor
Found in lib/locomotive/steam/middlewares/missing_translations.rb - About 55 mins to fix

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?
Severity: Minor
Found in app/models/locomotive/concerns/account/api_key.rb - About 55 mins to fix

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?
Severity: Minor
Found in app/helpers/locomotive/shared/pages_helper.rb - About 45 mins to fix

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]
Severity: Minor
Found in app/services/locomotive/content_entry_service.rb - About 45 mins to fix

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|
Severity: Minor
Found in app/models/locomotive/concerns/site/access_points.rb - About 45 mins to fix

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]
Severity: Minor
Found in app/services/locomotive/page_tree_service.rb - About 45 mins to fix

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?
Severity: Minor
Found in app/services/locomotive/page_parsing_service.rb - About 45 mins to fix

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) {
Severity: Minor
Found in app/javascript/src/locomotive/editor/services/preview_service.js - About 45 mins to fix

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

Severity: Minor
Found in app/models/locomotive/content_type.rb - About 45 mins to fix

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)
Severity: Minor
Found in app/services/locomotive/page_parsing_service.rb - About 45 mins to fix

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;

Severity: Minor
Found in app/javascript/src/locomotive/editor/utils/misc.js - About 45 mins to fix

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
Severity: Minor
Found in app/services/locomotive/content_entry_import_service.rb - About 45 mins to fix

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;
Severity: Minor
Found in app/javascript/src/locomotive/editor/views/sections/edit/block_list.js - About 45 mins to fix

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
Severity: Minor
Found in app/models/locomotive/concerns/content_entry/csv.rb - About 45 mins to fix

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
Severity: Minor
Found in lib/locomotive/mongoid/patches.rb - About 45 mins to fix

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|
Severity: Minor
Found in app/controllers/locomotive/page_content_controller.rb - About 45 mins to fix

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) {
Severity: Minor
Found in app/javascript/src/locomotive/editor/actions/section_actions.js - About 35 mins to fix

    Function searchForResources has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    export function searchForResources(url, locale, type, q, scope) {
    Severity: Minor
    Found in app/javascript/src/locomotive/editor/services/api.js - About 35 mins to fix

      Function updateSectionText has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      export function updateSectionText(_window, section, blockId, settingId, value) {
      Severity: Minor
      Found in app/javascript/src/locomotive/editor/services/preview_service.js - About 35 mins to fix

        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?
        Severity: Minor
        Found in app/models/locomotive/content_type.rb - About 35 mins to fix

        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

        Severity
        Category
        Status
        Source
        Language