artirix/browsercms

View on GitHub

Showing 119 of 119 total issues

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

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

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

          def destroy
            respond_to do |format|
              if @page.destroy
                message = "Page '#{@page.name}' was deleted."
                format.html { flash[:notice] = message; redirect_to(sitemap_url) }
      Severity: Major
      Found in app/controllers/cms/pages_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/cms/links_controller.rb on lines 46..55

      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 64.

      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

          def destroy
            respond_to do |format|
              if @link.destroy
                message = "Link '#{@link.name}' was deleted."
                format.html { flash[:notice] = message; redirect_to(sitemap_url) }
      Severity: Major
      Found in app/controllers/cms/links_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/cms/pages_controller.rb on lines 57..66

      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 64.

      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

              put:function (message) {
                  message['type'] = 'POST';
                  message['data'] = message['data'] || {}
                  message['data']['_method'] = 'PUT';
      
      
      Severity: Major
      Found in app/assets/javascripts/cms/ajax.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/cms/ajax.js on lines 44..50

      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 65.

      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

              delete:function (message) {
                  message['type'] = 'POST';
                  message['data'] = message['data'] || {}
                  message['data']['_method'] = 'DELETE';
                  $.ajax(message);
      Severity: Major
      Found in app/assets/javascripts/cms/ajax.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/cms/ajax.js on lines 25..32

      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 65.

      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

      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

            Severity
            Category
            Status
            Source
            Language