artirix/browsercms

View on GitHub
app/models/cms/page.rb

Summary

Maintainability
D
2 days
Test Coverage

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

    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

      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 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 copy_connectors has 26 lines of code (exceeds 25 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 1 hr to fix

        Method move_connector has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def move_connector(connector, direction)
            transaction do
              raise "Connector is nil" unless connector
              raise "Direction is nil" unless direction
              orientation = direction[/_/] ? "#{direction.sub('_', ' the ')} of" : "#{direction} within"
        Severity: Minor
        Found in app/models/cms/page.rb - About 55 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 in_section? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def in_section?(section_or_section_name)
            found = false
            ancestors.each do |a|
              if section_or_section_name.is_a?(String)
                if a.name == section_or_section_name
        Severity: Minor
        Found in app/models/cms/page.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 add_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_content(connectable, container=:main)
            transaction do
              raise "Connectable is nil" unless connectable
              raise "Container is required" if container.blank?
              #should_publish =  published? &&
        Severity: Minor
        Found in app/models/cms/page.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 remove_connector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def remove_connector(connector)
            transaction do
              raise "Connector is nil" unless connector
              update_attributes(version_comment: "#{connector.connectable} was removed from the '#{connector.container}' container", publish_on_save: false)
        
        
        Severity: Minor
        Found in app/models/cms/page.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