rails/app/controllers/application_controller.rb
Class ApplicationController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ApplicationController < ActionController::Base
include Clipboard
include Pundit
protect_from_forgery prepend: false
Method not_authorized_error_message
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def not_authorized_error_message(options={})
resource_type = options[:resource_type] || ''
resource_name = options[:resource_name] || ''
additional_info = options[:additional_info] || ''
- 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 pundit_user_not_authorized
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def pundit_user_not_authorized(exception)
# without the no-store Chrome will cache this redirect in some cases
# for example if a student tries to access a collection page, and then they
# log out and try to access it again. In this case Chrome sends them to the
# cached location of "/my-classes". By default rails adds 'no-cache' but that isn't
- 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
Consider simplifying this complex logical expression. Open
Open
if request.format && request.format.html? && current_settings && current_settings.require_user_consent? && !current_visitor.portal_student.nil? && !current_visitor.asked_age?
unless session_sensitive_path
flash.keep
redirect_to(ask_consent_portal_student_path(current_visitor.portal_student))
end
Consider simplifying this complex logical expression. Open
Open
if request.format && request.format.html? && current_settings && current_settings.use_student_security_questions && !current_visitor.portal_student.nil? && current_visitor.security_questions.size < 3
unless session_sensitive_path
flash.keep
redirect_to(edit_user_security_questions_path(current_visitor))
end