Class Page
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Page < ActiveRecord::Base
include ActiveSupport::Inflector
include TheSortableTree::Scopes
# Adding has_many for all field types
Method ids_by_params
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def ids_by_params(params)
_hash = {}
params.each_pair do |key, value|
next if key == 'utf8'
- 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 find_page_in_branch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_page_in_branch(cname)
Template.find_by(code_name: cname.singularize).tap {|t| t || return
(descendants.where(template_id: t.id) if cname == cname.pluralize).tap {|r| r ||= []
return r.empty? ? ancestors.find_by(template_id: t.id) : r}}
end
- 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 search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def search(what = nil)
_hash, _array = {}, []
@where = Page.find_by(full_url: @where) if @where.is_a?(String)
_array = ['lft > ? and rgt < ?', @where.lft, @where.rgt] if @where
if what
- 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"