AlchemyCMS/alchemy_cms

View on GitHub

Showing 41 of 55 total issues

Class Page has 46 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 6 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

File page.rb has 339 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 4 hrs to fix

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

  class Resource
    attr_accessor :resource_relations, :model_associations
    attr_reader :model

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

Class Content has 26 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 3 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

File pages_controller.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

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

      def element_editor_classes(element)
        [
          'element-editor',
          element.content_definitions.present? ? 'with-contents' : 'without-contents',
          element.nestable_elements.any? ? 'nestable' : 'not-nestable',
Severity: Minor
Found in app/helpers/alchemy/admin/elements_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 31 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 render_essence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def render_essence(content, part = :view, options = {}, html_options = {})
      options = {for_view: {}, for_editor: {}}.update(options)
      if content.nil?
        return part == :view ? "" : warning('Content is nil', Alchemy.t(:content_not_found))
      elsif content.essence.nil?
Severity: Minor
Found in app/helpers/alchemy/essences_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 render_navigation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def render_navigation(options = {}, html_options = {})
      options = {
        submenu: false,
        all_sub_menues: false,
        from_page: @root_page || Language.current_root_page,
Severity: Minor
Found in app/helpers/alchemy/pages_helper.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 page_hash has a Cognitive Complexity of 9 (exceeds 5 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 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 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 encoded_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def encoded_image(image, options = {})
      target_format = options[:format] || default_render_format

      unless target_format.in?(Alchemy::Picture.allowed_filetypes)
        raise WrongImageFormatError.new(self, target_format)
Severity: Minor
Found in app/models/alchemy/picture/url.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 render_element has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def render_element(*args)
      if args.length == 4
        element, _part, options, counter = *args
        Alchemy::Deprecation.warn "passing a `part` parameter as second argument to `render_element` has been removed without replacement. " \
          "You can safely remove it."
Severity: Minor
Found in app/helpers/alchemy/elements_helper.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
Severity
Category
Status
Source
Language