Class Page
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class Cms::Page < ActiveRecord::Base
def actual_path
path
end
File page.rb
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Cms::Page < ActiveRecord::Base
def actual_path
path
end
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}" }
- Read upRead up
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
- Read upRead up
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}" }
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"
- Read upRead up
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
- Read upRead up
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? &&
- Read upRead up
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)
- Read upRead up
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"