AlchemyCMS/alchemy_cms

View on GitHub

Showing 31 of 59 total issues

Class Page has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Page < BaseRecord
    include Alchemy::Hints
    include Alchemy::Logger
    include Alchemy::Taggable

Severity: Minor
Found in app/models/alchemy/page.rb - About 5 hrs to fix

Class PagesController has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PagesController < Alchemy::Admin::BaseController
      include OnPageLayout::CallbacksRunner

      helper "alchemy/pages"

Severity: Minor
Found in app/controllers/alchemy/admin/pages_controller.rb - About 4 hrs to fix

Class Resource has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Resource
    attr_accessor :resource_relations, :model_associations
    attr_reader :model

    DEFAULT_SKIPPED_ATTRIBUTES = %w(id created_at creator_id)
Severity: Minor
Found in lib/alchemy/resource.rb - About 3 hrs to fix

File page.rb has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Alchemy
  class Page < BaseRecord
    include Alchemy::Hints
    include Alchemy::Logger
    include Alchemy::Taggable
Severity: Minor
Found in app/models/alchemy/page.rb - About 2 hrs to fix

Class Content has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Content < BaseRecord
    include Alchemy::Logger
    include Alchemy::Hints

    # Concerns
Severity: Minor
Found in app/models/alchemy/content.rb - About 2 hrs to fix

Method pages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def pages
      tree = []
      path = [{id: object.parent_id, children: tree}]
      page_list = object.self_and_descendants
      base_level = object.level - 1
Severity: Minor
Found in app/serializers/alchemy/page_tree_serializer.rb - About 2 hrs 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

Class InstallGenerator has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class InstallGenerator < ::Rails::Generators::Base
      desc "Installs Alchemy into your App."

      class_option :auto_accept,
        type: :boolean,
Severity: Minor
Found in lib/generators/alchemy/install/install_generator.rb - About 2 hrs to fix

Method try_seed_pages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def try_seed_pages
        return unless page_seeds_file.file?

        if Alchemy::Page.exists?
          desc "Seeding Alchemy pages"
Severity: Minor
Found in lib/alchemy/seeder.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 delete_multiple has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def delete_multiple
        if request.delete? && params[:picture_ids].present?
          pictures = Picture.find(params[:picture_ids])
          names = []
          not_deletable = []
Severity: Minor
Found in app/controllers/alchemy/admin/pictures_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 render_attribute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def render_attribute(resource, attribute, options = {})
      attribute_value = resource.send(attribute[:name])
      if attribute[:relation]
        record = resource.send(attribute[:relation][:name])
        value = record.present? ? record.send(attribute[:relation][:attr_method]) : Alchemy.t(:not_found)
Severity: Minor
Found in lib/alchemy/resources_helper.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 page_hash has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def page_hash(page, has_children, level, folded)
      p_hash = {
        id: page.id,
        name: page.name,
        public: page.public?,
Severity: Minor
Found in app/serializers/alchemy/page_tree_serializer.rb - About 1 hr to fix

Method pages has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def pages
      tree = []
      path = [{id: object.parent_id, children: tree}]
      page_list = object.self_and_descendants
      base_level = object.level - 1
Severity: Minor
Found in app/serializers/alchemy/page_tree_serializer.rb - About 1 hr to fix

Method delete_multiple has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def delete_multiple
        if request.delete? && params[:picture_ids].present?
          pictures = Picture.find(params[:picture_ids])
          names = []
          not_deletable = []
Severity: Minor
Found in app/controllers/alchemy/admin/pictures_controller.rb - About 1 hr to fix

Method render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def render
      return if picture.blank?

      output = caption ? img_tag + caption : img_tag

Severity: Minor
Found in app/models/alchemy/essence_picture_view.rb - About 55 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 visit_nodes has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def visit_nodes(nodes, my_left, parent, depth, tree, url, restricted)
Severity: Major
Found in app/controllers/alchemy/admin/pages_controller.rb - About 50 mins to fix

Method run_on_page_layout_callbacks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def run_on_page_layout_callbacks
        OnPageLayout.callbacks.each do |page_layout, callbacks|
          next unless call_page_layout_callback_for?(page_layout)

          callbacks.each do |callback|
Severity: Minor
Found in lib/alchemy/on_page_layout/callbacks_runner.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 remove_orphaned_contents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def remove_orphaned_contents
        puts "\n## Removing orphaned contents"
        contents = Alchemy::Content.unscoped.all
        if contents.any?
          orphaned_contents = contents.select do |content|
Severity: Minor
Found in lib/alchemy/tasks/tidy.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 get_all_by_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def get_all_by_attributes(attributes)
        return [] if attributes.blank?

        if attributes.is_a? Hash
          layouts = []
Severity: Minor
Found in lib/alchemy/page_layout.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 content_definitions_from_elements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def content_definitions_from_elements(definitions)
        definitions.collect do |el|
          next if el["contents"].blank?

          contents = el["contents"].select do |c|
Severity: Minor
Found in lib/alchemy/tinymce.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
        @page = Page.find(params[:element][:page_id])
        Element.transaction do
          if @paste_from_clipboard = params[:paste_from_clipboard].present?
            @element = paste_element_from_clipboard
Severity: Minor
Found in app/controllers/alchemy/admin/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

Severity
Category
Status
Source
Language