Class ApplicationController
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include ApplicationShared
include Foreman::Controller::Flash
include Foreman::Controller::Authorize
File application_controller.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include ApplicationShared
include Foreman::Controller::Flash
include Foreman::Controller::Authorize
Method process_error
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def process_error(hash = {})
hash[:object] ||= instance_variable_get("@#{controller_name.singularize}")
if hash[:render].blank? && hash[:redirect].blank?
case action_name
when "create" then hash[:render] = "new"
- 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 setup_search_options
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def setup_search_options
@original_search_parameter = params[:search]
params[:search] ||= ""
params.each do |param, value|
if param =~ /(\w+)_id$/
- 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 taxonomy_scope
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def taxonomy_scope
if params[controller_name.singularize.to_sym]
@organization = Organization.find_by_id(params[controller_name.singularize.to_sym][:organization_id])
@location = Location.find_by_id(params[controller_name.singularize.to_sym][:location_id])
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 process_success
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process_success(hash = {})
hash[:object] ||= instance_variable_get("@#{controller_name.singularize}")
hash[:object_name] ||= hash[:object].to_s
unless hash[:success_msg]
hash[:success_msg] = case action_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 resource_path
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def resource_path(type)
return '' if type.nil?
path = type.pluralize.underscore + "_path"
prefix, suffix = path.split('/', 2)
- 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 sti_clean_up
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sti_clean_up(e)
require_login rescue false
Foreman::Logging.exception("Action failed", e) unless User.current&.admin?
@unknown_class_name = e.message.match(/subclass: '(.*)'\./)[1]
@parent_class = e.message.match(/overwrite (.*)\.inheritance_column/)[1].constantize
- 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"