artirix/browsercms

View on GitHub

Showing 87 of 119 total issues

Method acts_as_content_block has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

        def acts_as_content_block(options={})
          defaults = {
              # Set default values here.
              allow_attachments: true,
              content_module: true,
Severity: Minor
Found in lib/cms/acts/content_block.rb - About 1 day 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 ContentBlockController has 52 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ContentBlockController < Cms::BaseController
    include Cms::ContentRenderingSupport

    allow_guests_to [:show_via_slug]

Severity: Major
Found in app/controllers/cms/content_block_controller.rb - About 7 hrs to fix

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

    class Cms::Page < ActiveRecord::Base
    
      def actual_path
        path
      end
    Severity: Minor
    Found in app/models/cms/page.rb - About 5 hrs to fix

      Method menu_items has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def menu_items(options = {})
            # Intialize parameters
            selected_page = options[:page] || @page
            return nil unless selected_page
            
      Severity: Minor
      Found in app/helpers/cms/menu_helper.rb - About 5 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

      Function tagList has 117 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        $.fn.tagList = function(tags) {
          var tagListInput = this;
          var tagSeparator = " ";
      
          var getTagList = function() {
      Severity: Major
      Found in app/assets/javascripts/jquery.taglist.js - About 4 hrs to fix

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

          class Attachment < ActiveRecord::Base
        
            MULTIPLE = 'multiple'
        
            SANITIZATION_REGEXES = [[/\s/, '_'], [/[&+()]/, '-'], [/[=?!'"{}\[\]#<>%]/, '']]
        Severity: Minor
        Found in app/models/cms/attachment.rb - About 3 hrs to fix

          File content_block_controller.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'cms/category_type'
          # This is not called directly
          # This is the base class for other content blocks
          module Cms
            class ContentBlockController < Cms::BaseController
          Severity: Minor
          Found in app/controllers/cms/content_block_controller.rb - About 3 hrs to fix

            Class Section has 29 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Section < ActiveRecord::Base
                flush_cache_on_change
            
                is_addressable no_dynamic_path: true, destroy_if: :deletable?
                # Cannot use dependent => :destroy to do this. Ancestry's callbacks trigger before the before_destroy callback.
            Severity: Minor
            Found in app/models/cms/section.rb - About 3 hrs to fix

              Class Portlet has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Portlet < ActiveRecord::Base
                  validates_presence_of :name
                  is_searchable
                  uses_soft_delete
                  has_content_type :module => :core
              Severity: Minor
              Found in app/models/cms/portlet.rb - About 3 hrs to fix

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

                class Cms::Page < ActiveRecord::Base
                
                  def actual_path
                    path
                  end
                Severity: Minor
                Found in app/models/cms/page.rb - About 3 hrs to fix

                  Class ContentType has 26 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class ContentType
                  
                      attr_accessor :name
                  
                      def initialize(options)
                  Severity: Minor
                  Found in app/models/cms/content_type.rb - About 3 hrs to fix

                    Method content_blocks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def content_blocks(content_block_name, options = {}, &block)
                        options     = DEFAULT_CONTENT_BLOCKS_OPTIONS.merge options
                        model_class = guess_model_class(content_block_name)
                    
                        # options to
                    Severity: Minor
                    Found in lib/cms/route_extensions.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

                    Method copy_connectors has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def copy_connectors(options={})
                        logger.debug { "Copying connectors from Page #{id} v#{options[:from_version_number]} to v#{options[:to_version_number]}." }
                    
                        c_found = connectors.for_page_version(options[:from_version_number]).order("#{Cms::Connector.table_name}.container, #{Cms::Connector.table_name}.position").to_a
                        logger.debug { "Found connectors #{c_found}" }
                    Severity: Minor
                    Found in app/models/cms/page.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

                    Method publish! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def publish!
                              did_publish = false
                              if new_record?
                                ActiveSupport::Deprecation.warn "Calling .publish! on a new record no longer saves the record. Call '.save' to persist and publish the record.", caller
                              else
                    Severity: Minor
                    Found in lib/cms/behaviors/publishing.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

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

                      def input(_wrapper_options = nil)
                        # New blocks will not have their attachments created yet.
                        object.ensure_attachment_exists if object.respond_to?(:ensure_attachment_exists)
                    
                        # Need to explictly use correct id (i.e. image_block_file) rather than the autogenerated one (i.e. image_block_attachments_attributes_0_attachment_name)
                    Severity: Minor
                    Found in app/inputs/file_picker_input.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

                    Function cmsContentToolbar has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        $.fn.cmsContentToolbar = function () {
                            var content_type = this.data('content_type')
                            var is_versioned = this.data('versioned')
                            var can_publish = this.data('can_publish')
                            var plural_title = this.data('plural_title')
                    Severity: Major
                    Found in app/assets/javascripts/cms/content_library.js - About 2 hrs to fix

                      Method create_content_table has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def create_content_table(table_name, options={}, &block)
                              defaults = {
                                  versioned: true,
                                  name: true
                              }

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

                          def complete
                            if params[:task_ids]
                              Task.where(["id in (?)", params[:task_ids]]).each do |t|
                                if t.assigned_to == current_user
                                  t.mark_as_complete!
                      Severity: Minor
                      Found in app/controllers/cms/tasks_controller.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

                      Method content_block_tr_tag has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def content_block_tr_tag(block)
                            cname = class_name_for(block)
                            can_modify = current_user.able_to_modify?(block)
                      
                            options = {}
                      Severity: Minor
                      Found in app/helpers/cms/content_block_helper.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

                      Method has_dynamic_attributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def has_dynamic_attributes(options={})
                                @has_dynamic_attributes = true
                                include InstanceMethods
                      
                                # Provide default options
                      Severity: Minor
                      Found in lib/cms/behaviors/dynamic_attributes.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

                      Severity
                      Category
                      Status
                      Source
                      Language