Showing 3 of 3 total issues
Method page_ancestry_options
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def page_ancestry_options(page)
pages = Spina::Page.active.regular_pages
pages = pages.where.not(id: page.subtree.ids) unless page.new_record? || !page.methods.include?(:subtree)
(flatten_nested_hash(pages.arrange(order: :position)).map do |page|
- 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_or_set_settings
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_or_set_settings
@setting = setting_class.first_or_create do |setting|
plugin.settings.each do |attribute, type|
setting.send("#{attribute}=", (type.is_a?(Hash) ? type.first.last : nil))
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 find_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_by(opts={})
all.find do |plugin|
matches = true
opts.each do |key, value|
matches = false unless plugin.send(key) == value
- 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"