artirix/browsercms

View on GitHub

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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        var selectNextTag = function() {
                          if(getSelectedTag().length > 0 && getSelectedTag().next().length > 0) {
                            selectTag(getSelectedTag().next())
                          } else {
                            selectTag(getFirstTag())
                    Severity: Major
                    Found in app/assets/javascripts/jquery.taglist.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/jquery.taglist.js on lines 108..114

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 83.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        var selectPrevTag = function() {
                          if(getSelectedTag().length > 0 && getSelectedTag().prev().length > 0) {
                            selectTag(getSelectedTag().prev())
                          } else {
                            selectTag(getFirstTag())
                    Severity: Major
                    Found in app/assets/javascripts/jquery.taglist.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/jquery.taglist.js on lines 116..122

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 83.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    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

                      Severity
                      Category
                      Status
                      Source
                      Language