owncloud/core

View on GitHub
apps/dav/lib/Connector/Sabre/Auth.php

Summary

Maintainability
C
1 day
Test Coverage

Function auth has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function auth(RequestInterface $request, ResponseInterface $response) {
        $forcedLogout = false;
        if (!$this->request->passesCSRFCheck() &&
            $this->requiresCSRFCheck()) {
            // In case of a fail with POST we need to recheck the credentials
Severity: Minor
Found in apps/dav/lib/Connector/Sabre/Auth.php - About 3 hrs 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 auth has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function auth(RequestInterface $request, ResponseInterface $response) {
        $forcedLogout = false;
        if (!$this->request->passesCSRFCheck() &&
            $this->requiresCSRFCheck()) {
            // In case of a fail with POST we need to recheck the credentials
Severity: Major
Found in apps/dav/lib/Connector/Sabre/Auth.php - About 2 hrs to fix

    Method validateUserPass has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function validateUserPass($username, $password) {
            if (\trim($username) === '') {
                return false;
            }
            if ($this->userSession->isLoggedIn() &&
    Severity: Minor
    Found in apps/dav/lib/Connector/Sabre/Auth.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if (\OC_User::handleApacheAuth() ||
                      //Fix for broken webdav clients
                      ($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === null) ||
                      //Well behaved clients that only send the cookie are allowed
                      ($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && ($request->getHeader('Authorization') === null || $request->getHeader('Authorization') === ''))
      Severity: Major
      Found in apps/dav/lib/Connector/Sabre/Auth.php - About 1 hr to fix

        Function validateUserPass has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function validateUserPass($username, $password) {
                if (\trim($username) === '') {
                    return false;
                }
                if ($this->userSession->isLoggedIn() &&
        Severity: Minor
        Found in apps/dav/lib/Connector/Sabre/Auth.php - 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

        Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                ISession $session,
                Session $userSession,
                IRequest $request,
                Manager $twoFactorManager,
                AccountModuleManager $accountModuleManager,
        Severity: Major
        Found in apps/dav/lib/Connector/Sabre/Auth.php - About 50 mins to fix

          Avoid too many return statements within this method.
          Open

                  return true;
          Severity: Major
          Found in apps/dav/lib/Connector/Sabre/Auth.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status