artirix/browsercms

View on GitHub

Showing 87 of 119 total issues

Method has_dynamic_attributes has 46 lines of code (exceeds 25 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

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

        def connected_to(b)
          if b.is_a?(Hash)
            obj = b[:connectable]
            if obj.class.versioned?
              ver = b[:version] ? b[:version] : obj.version
    Severity: Minor
    Found in app/models/cms/page.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 validates_attachment_size has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def validates_attachment_size(name, options = {})
    
              min = options[:greater_than] || (options[:in] && options[:in].first) || 0
              max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0)
              range = (min..max)
    Severity: Minor
    Found in lib/cms/behaviors/attaching.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 menu_items has 42 lines of code (exceeds 25 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 1 hr to fix

      Method is_searchable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def is_searchable(options={})
                @is_searchable = true
                @searchable_columns = options[:searchable_columns] ? options[:searchable_columns].map(&:to_sym) : [:name]
                extend ClassMethods
              
      Severity: Minor
      Found in lib/cms/behaviors/searching.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_content_table has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

            def render_connectable(content_block)
              if content_block
                if content_block.class.renderable?
                  Rails.logger.debug "Rendering connectable #{content_block.class} ##{content_block.id} #{"v#{content_block.version}" if content_block.respond_to?(:version)}"
                  content_block.perform_render(controller)
        Severity: Minor
        Found in app/helpers/cms/rendering_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 prepare_connectables_for_render has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def prepare_connectables_for_render
              @_connectors = @page.current_connectors
              @_connectables = @page.contents
        
              unless (logged_in? && current_user.able_to?(:administrate, :edit_content, :publish_content))
        Severity: Minor
        Found in lib/cms/content_rendering_support.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 is_addressable has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def is_addressable(options={})
                has_one_options = {as: :node, inverse_of: :node, class_name: 'Cms::SectionNode', validate: true}
                unless options[:destroy_if]
                  has_one_options[:dependent] = :destroy
                else
        Severity: Minor
        Found in lib/cms/concerns/can_be_addressable.rb - About 1 hr to fix

          Method content_blocks has 33 lines of code (exceeds 25 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 1 hr to fix

            Method render_breadcrumbs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def render_breadcrumbs(options={})
                  return "" unless current_page
            
                  start = options[:from_top] || 0
                  show_parent = options[:show_parent].nil? ? false : options[:show_parent]
            Severity: Minor
            Found in app/helpers/cms/page_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 is_addressable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def is_addressable(options={})
                    has_one_options = {as: :node, inverse_of: :node, class_name: 'Cms::SectionNode', validate: true}
                    unless options[:destroy_if]
                      has_one_options[:dependent] = :destroy
                    else
            Severity: Minor
            Found in lib/cms/concerns/can_be_addressable.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 redirect_non_cms_users_to_public_site has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def redirect_non_cms_users_to_public_site
                  @show_toolbar = false
                  if using_cms_subdomains?
                    logger.debug "Using cms subdomain is enabled"
                    if request_is_for_cms_subdomain?
            Severity: Minor
            Found in app/controllers/cms/content_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 perform_render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def perform_render(controller)
                    return "Exception: #{@render_exception}" if @render_exception
            
            
                    unless @controller
            Severity: Minor
            Found in lib/cms/behaviors/rendering.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 publish! has 30 lines of code (exceeds 25 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 1 hr to fix

              Method update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def update
                    content_block = Content.find_draft(params[:content_name], params[:id])
                    content_block.update_attributes(filtered_content(content_block))
                    @page = Page.find_draft(params[:page_id].to_i)
                    if (!@page.live?)
              Severity: Minor
              Found in app/controllers/cms/inline_content_controller.rb - About 1 hr to fix

                Function init has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    init:function (editor) {
                        editor.ui.addButton('DeleteContent', {
                            label:'Remove this content from the page (It will remain in Content Library)',
                            command:'deleteContent',
                            toolbar:'tools'
                Severity: Minor
                Found in app/assets/javascripts/ckeditor/plugins/delete_content/plugin.js - About 1 hr to fix

                  Function saveChanges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      saveChanges: function(currentEditor, afterSave) {
                        var block_id = currentEditor.name;
                        var block = $("#" + block_id);
                        var attribute = block.data('attribute');
                        var content_name = block.data('content-name');
                  Severity: Minor
                  Found in app/assets/javascripts/cms/page_editor.js - About 1 hr to fix

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

                            def is_versioned(options={})
                              @is_versioned = true
                    
                              @version_table_name = (options[:version_table_name] || "#{table_name.singularize}_versions").to_s
                    
                    
                    Severity: Minor
                    Found in lib/cms/behaviors/versioning.rb - About 1 hr to fix

                      Method acts_as_content_block has 27 lines of code (exceeds 25 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 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language