Showing 3 of 5 total issues
Class Page
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Page < ActiveRecord::Base
include Kuhsaft::Engine.routes.url_helpers
include Kuhsaft::Orderable
include Kuhsaft::Translatable
include Kuhsaft::BrickList
Method model_attribute_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def model_attribute_field(resource, column_name, f)
if resource.class.respond_to?(:uploaders) && resource.class.uploaders.keys.include?(column_name.to_sym)
f.input column_name, as: :file
elsif association_class(resource, column_name) == Kuhsaft::Page
route_input f, column_name, page_routes
- 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 show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def show
if @page.present? && @page.redirect? && @page.redirect_url.present?
redirect_url = @page.redirect_url.sub(/\A\/+/, '') # remove all preceding slashes
session[:kuhsaft_referrer] = @page.id
redirect_to "/#{redirect_url}"
- 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"