Showing 16 of 18 total issues
Method import!
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def import!(path = self.path, parent = nil)
Dir["#{path}*/"].each do |path|
slug = path.split('/').last
page = if parent
- 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 initialize
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
if user
if user.type.eql?(:super_user)
can :manage, :all
- 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 included
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
before_action :configure_permitted_parameters, if: :devise_controller?
- 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 import!
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import!(path = self.path, parent = nil)
Dir["#{path}*/"].each do |path|
slug = path.split('/').last
page = if parent
Method render_page
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def render_page(status = 200)
cached_timeout = @cms_page.cached_timeout.to_i
if cached_timeout > 0
fresh_when etag: @cms_page, last_modified: @cms_page.updated_at.utc, public: true
- 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 included
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.extend ClassMethods
base.class_eval do
Method update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update
user = user_params
raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if user[:type_id].eql?(1) && !current_cms_fortress_user.type.eql?(:super_user)
- 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 initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
if user
if user.type.eql?(:super_user)
can :manage, :all
Method export!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def export!
prepare_folder!(self.path)
self.site.pages.each do |page|
page.slug = 'index' if page.slug.blank?
- 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 initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
self.class.send(:include, Rails.application.routes.url_helpers)
@theme = :default
@enable_page_workflow = true
@enable_page_caching = true
Method included
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
before_action :configure_permitted_parameters, if: :devise_controller?
Method cms_fortress_routes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cms_fortress_routes(options = {})
path = options[:path] || "cms-admin"
devise_for "cms/fortress/users",
:path => path,
Method create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
@cms_fortress_user = @site.users.build(user_params)
raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if @cms_fortress_user.type.eql?(:super_user) && !current_cms_fortress_user.type.eql?(:super_user)
@cms_fortress_user.site_id = nil if @cms_fortress_user.type.eql?(:super_user)
- 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 export!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def export!
prepare_folder!(self.path)
self.site.pages.each do |page|
page.slug = 'index' if page.slug.blank?
Avoid deeply nested control flow statements. Open
setup_role(role_detail, user) if defined?(setup_role)
Method topnav_resource_item
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def topnav_resource_item(key, resource)
if ["divider", "dropdown-header"].include?(resource[:name])
title = resource[:title].nil? ? "" : t(resource[:title], site_name: @site.label)
content_tag(:li, title, class: resource[:name], role: "presentation")
else
- 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"