artirix/browsercms

View on GitHub
app/controllers/cms/content_block_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

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

    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

      Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            return render_not_implemented if readonly?
      
            if create_block
              after_create_on_success
      Severity: Minor
      Found in app/controllers/cms/content_block_controller.rb - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def update
            return render_not_implemented if readonly?
      
            if update_block
              after_update_on_success
      Severity: Minor
      Found in app/controllers/cms/content_block_controller.rb - About 45 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 check_permissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_permissions
            case action_name
            when "index", "show", "new", "create", "version", "versions"
              # Allow
            when "edit", "update", "inline"
      Severity: Minor
      Found in app/controllers/cms/content_block_controller.rb - About 35 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 do_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def do_command(result)
            load_block
            if yield
              flash[:notice] = "#{content_type_name.demodulize.titleize} '#{@block.name}' was #{result}" unless request.xhr?
            else
      Severity: Minor
      Found in app/controllers/cms/content_block_controller.rb - About 25 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

      There are no issues that match your filters.

      Category
      Status