concord-consortium/rigse

View on GitHub
rails/app/controllers/application_controller.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class ApplicationController has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  include Clipboard
  include Pundit

  protect_from_forgery prepend: false
Severity: Minor
Found in rails/app/controllers/application_controller.rb - About 3 hrs to fix

    Method not_authorized_error_message has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def not_authorized_error_message(options={})
        resource_type = options[:resource_type] || ''
        resource_name = options[:resource_name] || ''
        additional_info = options[:additional_info] || ''
    
    
    Severity: Minor
    Found in rails/app/controllers/application_controller.rb - About 1 hr to fix

    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

      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
    Severity: Minor
    Found in rails/app/controllers/application_controller.rb - About 55 mins to fix

    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

        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
    Severity: Major
    Found in rails/app/controllers/application_controller.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      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
      Severity: Major
      Found in rails/app/controllers/application_controller.rb - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status