locomotivecms/engine

View on GitHub

Showing 169 of 169 total issues

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

      Method cast_metafields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def cast_metafields(namespace)
                return nil if namespace.blank? || !has_metafields?
      
                schema = self.metafields_schema.find { |s| s['name'] == namespace }
                values = self.metafields[namespace]
      Severity: Minor
      Found in app/models/locomotive/concerns/site/metafields.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

      Method build_tree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_tree
            pages, page_not_found = pages_with_minimun_attributes, nil
      
            [].tap do |tree|
              while page = pages.shift
      Severity: Minor
      Found in app/services/locomotive/page_tree_service.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

      Method render_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_index
            if @editable_elements
              @editable_elements_by_block = parsing_service.group_and_sort_editable_elements(@editable_elements)
              @blocks = parsing_service.blocks_from_grouped_editable_elements(@editable_elements_by_block)
            end
      Severity: Minor
      Found in app/controllers/locomotive/editable_elements_controller.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

      Method sanitize_attributes! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def sanitize_attributes!(attributes)
            # needed to get the custom fields
            _entry = content_type.entries.build
      
            # if the user deletes all the entries of a many_to_many field,
      Severity: Minor
      Found in app/services/locomotive/content_entry_service.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

      Method order_by_definition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def order_by_definition(reverse_order = false)
                direction = self.order_manually? ? 'asc' : self.order_direction || 'asc'
      
                if reverse_order
                  direction = (direction == 'asc' ? 'desc' : 'asc')
      Severity: Minor
      Found in app/models/locomotive/concerns/content_type/order_by.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

      Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(site, attributes, raise_if_not_valid = false)
            site.attributes = attributes
      
            new_locales = site.locales_changed? ? site.locales - site.locales_was : nil
            previous_default_locale = site.default_locale_was
      Severity: Minor
      Found in app/services/locomotive/site_service.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

      Method set_raw_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_raw_template
                return unless site
      
                site.with_default_locale do
                  if layout_id == 'parent'
      Severity: Minor
      Found in app/models/locomotive/concerns/page/layout.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

      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)
      Severity: Minor
      Found in app/services/locomotive/membership_service.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                put ':id' do
                  if @translation = current_site.translations.by_id_or_key(params[:id]).first
                    authorize @translation, :update?
                  else
                    authorize Translation, :create?
      Severity: Minor
      Found in app/api/locomotive/api/resources/translation_resource.rb and 2 other locations - About 35 mins to fix
      app/api/locomotive/api/resources/section_resource.rb on lines 63..76
      app/api/locomotive/api/resources/snippet_resource.rb on lines 61..73

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                put ':id' do
                  if @snippet = current_site.snippets.by_id_or_slug(params[:id]).first
                    authorize @snippet, :update?
                  else
                    authorize Snippet, :create?
      Severity: Minor
      Found in app/api/locomotive/api/resources/snippet_resource.rb and 2 other locations - About 35 mins to fix
      app/api/locomotive/api/resources/section_resource.rb on lines 63..76
      app/api/locomotive/api/resources/translation_resource.rb on lines 62..74

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                put ':id' do
                  if @section = current_site.sections.by_id_or_slug(params[:id]).first
                    authorize @section, :update?
                  else
                    authorize Section, :create?
      Severity: Minor
      Found in app/api/locomotive/api/resources/section_resource.rb and 2 other locations - About 35 mins to fix
      app/api/locomotive/api/resources/snippet_resource.rb on lines 61..73
      app/api/locomotive/api/resources/translation_resource.rb on lines 62..74

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            {image && (
              <div className="editor-list-item--image" style={{ backgroundImage: `url("${image}")` }}>
              </div>
            )}
      app/javascript/src/locomotive/editor/views/sections/list/dropzone/section.js on lines 15..18
      app/javascript/src/locomotive/editor/views/sections/list/simple/section.js on lines 18..21

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 45.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            {image && (
              <div className="editor-list-item--image" style={{ backgroundImage: `url("${image}")` }}>
              </div>
            )}
      app/javascript/src/locomotive/editor/views/sections/edit/block.js on lines 13..16
      app/javascript/src/locomotive/editor/views/sections/list/dropzone/section.js on lines 15..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 45.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Avoid too many return statements within this function.
      Open

          return null;
      Severity: Major
      Found in app/javascript/src/locomotive/editor/hoc/with_editing_section.js - About 30 mins to fix

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

              {image && (
                <div className="editor-list-item--image" style={{ backgroundImage: `url("${image}")` }}>
                </div>
              )}
        app/javascript/src/locomotive/editor/views/sections/edit/block.js on lines 13..16
        app/javascript/src/locomotive/editor/views/sections/list/simple/section.js on lines 18..21

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          handleSectionChanged(newAnchor) {
            this._handleChange(
              update(this.state.settings, { anchor: { $set: newAnchor } })
            );
          }
        app/javascript/src/locomotive/editor/views/pickers/urls/types/content_entry.js on lines 62..66

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          handleNewWindowChanged(checked) {
            this._handleChange(
              update(this.state.settings, { new_window: { $set: checked } })
            );
          }
        app/javascript/src/locomotive/editor/views/pickers/urls/types/content_entry.js on lines 56..60

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language