locomotivecms/engine

View on GitHub

Showing 91 of 169 total issues

Method subscribe_to_sections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def subscribe_to_sections(sections)
      ActiveSupport::Notifications.subscribe('steam.parse.section') do |name, start, finish, id, payload|
        page, block, attributes = payload[:page], payload[:block], payload[:attributes]

        if attributes[:is_dropzone]
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

Method ensure_target_klass_name_security has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def ensure_target_klass_name_security
          return if !self.templatized? || self.target_klass_name.blank?

          if self.target_klass_name =~ /^Locomotive::ContentEntry([a-z0-9]+)$/
            content_type = Locomotive::ContentType.find($1)
Severity: Minor
Found in app/models/locomotive/concerns/page/templatized.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

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 next_or_previous has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def next_or_previous(matcher = :gt)
          # the matchers is supposed to be fine for the default direction, meaning 'asc'
          # if the direction is not ascending, we need to reverse the matcher
          matcher = matcher == :gt ? :lt : :gt if self.content_type.order_direction != 'asc'

Severity: Minor
Found in app/models/locomotive/concerns/content_entry/next_previous.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 bulk_create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def bulk_create(list)
      list = list.values if list.is_a?(Hash)

      assets = list.map { |params| create_or_update(params) }
        
Severity: Minor
Found in app/services/locomotive/content_asset_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 prepare_options_for_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_options_for_all(options)
      { where: prepare_where_statement(options) }.tap do |_options|
        unless options[:no_pagination]
          _options[:page]     = options[:page] || 1
          _options[:per_page] = options[:per_page] || Locomotive.config.ui[:per_page]
Severity: Minor
Found in app/services/locomotive/content_entry_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 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 handle_no_account_or_site has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_no_account_or_site(env, request)
        if Locomotive::Account.count == 0
          redirect_to((Locomotive.config.enable_registration ? sign_up_path : sign_in_path))
        elsif default_host?(request)
          redirect_to(sign_in_path)
Severity: Minor
Found in lib/locomotive/middlewares/site.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