owncloud/core

View on GitHub
lib/private/legacy/user.php

Summary

Maintainability
C
1 day
Test Coverage

OC_User has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class OC_User {
    /**
     * @return \OC\User\Session
     */
    public static function getUserSession() {
Severity: Minor
Found in lib/private/legacy/user.php - About 4 hrs to fix

    File user.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @author Aldo "xoen" Giambelluca <xoen@xoen.org>
     * @author Andreas Fischer <bantu@owncloud.com>
     * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
    Severity: Minor
    Found in lib/private/legacy/user.php - About 2 hrs to fix

      Function setupBackends has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function setupBackends() {
              OC_App::loadApps(['prelogin']);
              $backends = \OC::$server->getSystemConfig()->getValue('user_backends', []);
              if (isset($backends['default']) && !$backends['default']) {
                  // clear default backends
      Severity: Minor
      Found in lib/private/legacy/user.php - 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 useBackend has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function useBackend($backend = 'database') {
              if ($backend instanceof \OCP\UserInterface) {
                  self::$_usedBackends[\get_class($backend)] = $backend;
                  \OC::$server->getUserManager()->registerBackend($backend);
              } else {
      Severity: Minor
      Found in lib/private/legacy/user.php - About 1 hr to fix

        Function useBackend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function useBackend($backend = 'database') {
                if ($backend instanceof \OCP\UserInterface) {
                    self::$_usedBackends[\get_class($backend)] = $backend;
                    \OC::$server->getUserManager()->registerBackend($backend);
                } else {
        Severity: Minor
        Found in lib/private/legacy/user.php - 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

        Function getDisplayName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getDisplayName($uid = null) {
                if ($uid) {
                    $user = \OC::$server->getUserManager()->get($uid);
                    if ($user) {
                        return $user->getDisplayName();
        Severity: Minor
        Found in lib/private/legacy/user.php - 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

        Function findFirstActiveUsedBackend has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function findFirstActiveUsedBackend() {
                foreach (self::$_usedBackends as $backend) {
                    if ($backend instanceof OCP\Authentication\IApacheBackend) {
                        if ($backend->isSessionActive()) {
                            return $backend;
        Severity: Minor
        Found in lib/private/legacy/user.php - 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