locomotivecms/engine

View on GitHub

Showing 91 of 169 total issues

Function buildSectionOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const buildSectionOptions = (findSectionDefinition, sections) => {
  return compact((sections || []).map(section => {
    // unknown section type, can happen if the data are messed up (first deployment)
    if (section.type === null) return null;

Severity: Minor
Found in app/javascript/src/locomotive/editor/views/pickers/urls/main.js - About 25 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 persist_editable_elements! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def persist_editable_elements!(page, parsed)
      modified_pages, pages = [], { page._id => page } # group modifications by page

      parsed[:elements].map! do |couple|
        _page, attributes = couple
Severity: Minor
Found in app/services/locomotive/page_parsing_service.rb - About 25 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 withApiFetching has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const withApiFetching = (source, options) => (Component) => {

  const _options = Object.assign({ pagination: false }, options);

  return class WithFetching extends React.Component {
Severity: Minor
Found in app/javascript/src/locomotive/editor/hoc/with_api_fetching.js - About 25 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 find_layout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def find_layout
          return if !self.allow_layout? || self.layout_id

          if self.raw_template =~ EXTENDS_FULLPATH_REGEX
            # first in the current locale
Severity: Minor
Found in app/models/locomotive/concerns/page/layout.rb - About 25 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 vignette_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def vignette_url
          if self.image?
            # In some case (like an invalid extension) the height, width can be nill
            # In that case we should directly return the url
            if self.width && self.height && self.width < 85 && self.height < 85
Severity: Minor
Found in app/models/locomotive/concerns/asset/vignette.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def create(attributes, raise_if_not_valid = false)
      if attributes[:handle].blank?
        attributes[:handle] = unique_handle
      end

Severity: Minor
Found in app/services/locomotive/site_service.rb - About 25 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 6 (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 return

Severity: Minor
Found in app/models/locomotive/concerns/content_type/class_helpers.rb - About 25 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 normalize_slug has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def normalize_slug(field)
          value = self.send(field)

          if self.slug.blank? && value.present?
            self.slug = value.clone
Severity: Minor
Found in app/models/locomotive/concerns/shared/slug.rb - About 25 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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(name, *args, &block)
          if field = find_field(name)
            if respond_to?(:"set_#{field.type}")
              public_send(:"set_#{field.type}", field, args.first)
            else
Severity: Minor
Found in app/api/locomotive/api/forms/content_entry_form.rb - About 25 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 remove! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def remove!
      record.class.uploaders.each do |_column, _|
        next if _column == column

        _mounter    = self.record.send(:_mounter, _column)
Severity: Minor
Found in lib/locomotive/carrierwave/patches.rb - About 25 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 filename_or_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def filename_or_image
      if object.persisted? && persisted_file?
        css = "current-file #{persisted_file.image? ? 'image' : ''}"
        template.content_tag :span, (image_html + filename_html).html_safe, class: css
      else
Severity: Minor
Found in app/inputs/locomotive/file_input.rb - About 25 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