rubycas/rubycas-client

View on GitHub
lib/casclient/frameworks/rails/filter.rb

Summary

Maintainability
D
2 days
Test Coverage

Method filter has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

          def filter(controller)
            raise "Cannot use the CASClient filter because it has not yet been configured." if config.nil?
            
            if @@fake_user
              controller.session[client.username_session_key] = @@fake_user
Severity: Minor
Found in lib/casclient/frameworks/rails/filter.rb - About 1 day 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 filter has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def filter(controller)
            raise "Cannot use the CASClient filter because it has not yet been configured." if config.nil?
            
            if @@fake_user
              controller.session[client.username_session_key] = @@fake_user
Severity: Major
Found in lib/casclient/frameworks/rails/filter.rb - About 3 hrs to fix

    Method unauthorized! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

              def unauthorized!(controller, vr = nil)
                format = nil
                unless controller.request.format.nil?
                  format = controller.request.format.to_sym
                end
    Severity: Minor
    Found in lib/casclient/frameworks/rails/filter.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

    Avoid deeply nested control flow statements.
    Open

                        if pgt
                          log.debug("Got PGT #{pgt.ticket.inspect} for PGT IOU #{pgt.iou.inspect}. This will be stored in the session.")
                          controller.session[:cas_pgt] = pgt
                          # For backwards compatibility with RubyCAS-Client 1.x configurations...
                          controller.session[:casfilterpgt] = pgt
    Severity: Major
    Found in lib/casclient/frameworks/rails/filter.rb - About 45 mins to fix

      Method redirect_to_cas_for_authentication has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                def redirect_to_cas_for_authentication(controller)
                  redirect_url = login_url(controller)
                  
                  if use_gatewaying?
                    controller.session[:cas_sent_to_gateway] = true
      Severity: Minor
      Found in lib/casclient/frameworks/rails/filter.rb - About 45 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

      Avoid too many return statements within this method.
      Open

                      return false
      Severity: Major
      Found in lib/casclient/frameworks/rails/filter.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                      return false
        Severity: Major
        Found in lib/casclient/frameworks/rails/filter.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                            return true
          Severity: Major
          Found in lib/casclient/frameworks/rails/filter.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return false
            Severity: Major
            Found in lib/casclient/frameworks/rails/filter.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return true
              Severity: Major
              Found in lib/casclient/frameworks/rails/filter.rb - About 30 mins to fix

                Method single_sign_out has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                          def single_sign_out(controller)
                            
                            # Avoid calling raw_post (which may consume the post body) if
                            # this seems to be a file upload
                            if content_type = controller.request.headers["CONTENT_TYPE"] &&
                Severity: Minor
                Found in lib/casclient/frameworks/rails/filter.rb - About 25 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

                There are no issues that match your filters.

                Category
                Status