locomotivecms/engine

View on GitHub
app/services/locomotive/content_entry_service.rb

Summary

Maintainability
A
1 hr
Test Coverage

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 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 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

There are no issues that match your filters.

Category
Status