SpinaCMS/Spina

View on GitHub

Showing 7 of 21 total issues

Method new_page_templates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def new_page_templates(resource: nil)
      page_collection = resource&.name || "main"
      @view_templates.map do |view_template|
        next if is_custom_undeletable_page?(view_template[:name])
        next if view_template[:exclude_from]&.include?(page_collection)
Severity: Minor
Found in lib/spina/theme.rb - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

      def create
        @images = params[:image][:files].map do |file|
          next if file.blank? # Skip the blank string posted by the hidden files[] field
          
          # Create the image and attach the file
Severity: Minor
Found in app/controllers/spina/admin/images_controller.rb - About 1 hr 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_or_set_settings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def find_or_set_settings
          @setting = setting_class.first_or_create do |setting|
            plugin.settings.each do |attribute, type|
              setting.send("#{attribute}=", (type.is_a?(Hash) ? type.first.last : nil))
            end
Severity: Minor
Found in app/controllers/spina/admin/settings_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 render_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def render_item(item)
        return nil unless item.materialized_path
        children = scoped_collection(item.children)

        content_tag(list_item_tag, class: list_item_css, data: {page_id: item.page_id, draft: (true if item.draft?) }) do
Severity: Minor
Found in app/presenters/spina/menu_presenter.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_theme has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def set_theme
      account = ::Spina::Account.first
      return if account.theme.present? && !no?("Theme '#{account.theme}' is set. Skip? [Yn]")

      theme = account.theme || themes.first
Severity: Minor
Found in lib/generators/spina/install_generator.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 find_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def find_by(opts={})
        all.find do |plugin|
          matches = true
          opts.each do |key, value|
            matches = false unless plugin.send(key) == value
Severity: Minor
Found in lib/spina/plugin.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def update
        Mobility.locale = @locale
        if @page.update(page_params)
          if @page.saved_change_to_draft? && @page.live?
            flash[:confetti] = t('spina.pages.published')
Severity: Minor
Found in app/controllers/spina/admin/pages_controller.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