owncloud/core

View on GitHub
lib/private/User/SyncService.php

Summary

Maintainability
C
1 day
Test Coverage

File SyncService.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 *
Severity: Minor
Found in lib/private/User/SyncService.php - About 2 hrs to fix

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

        private function syncHome(Account $a, UserInterface $backend) {
            // Fallback for backends that dont yet use the new interfaces
            $providesHome = $backend instanceof IProvidesHomeBackend || $backend->implementsActions(\OC_User_Backend::GET_HOME);
            $uid = $a->getUserId();
            // Log when the backend returns a string that is a different home to the current value
    Severity: Minor
    Found in lib/private/User/SyncService.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 syncHome has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function syncHome(Account $a, UserInterface $backend) {
            // Fallback for backends that dont yet use the new interfaces
            $providesHome = $backend instanceof IProvidesHomeBackend || $backend->implementsActions(\OC_User_Backend::GET_HOME);
            $uid = $a->getUserId();
            // Log when the backend returns a string that is a different home to the current value
    Severity: Minor
    Found in lib/private/User/SyncService.php - About 1 hr to fix

      Function syncState has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          private function syncState(Account $a) {
              $uid = $a->getUserId();
              list($hasKey, $value) = $this->readUserConfig($uid, 'core', 'enabled');
              if ($hasKey) {
                  if ($value === 'true') {
      Severity: Minor
      Found in lib/private/User/SyncService.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

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

          public function run(UserInterface $backend, \Traversable $userIds, \Closure $callback = null) {
              // update existing and insert new users
              foreach ($userIds as $uid) {
                  try {
                      $account = $this->createOrSyncAccount($uid, $backend);
      Severity: Minor
      Found in lib/private/User/SyncService.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

      Method checkIfAccountReappeared has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function checkIfAccountReappeared(Account $a, array &$removed, array &$reappeared, UserInterface $backend, $backendClass) {
      Severity: Minor
      Found in lib/private/User/SyncService.php - About 35 mins to fix

        Function syncQuota has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function syncQuota(Account $a, UserInterface $backend) {
                $uid = $a->getUserId();
                $quota = null;
                if ($backend instanceof IProvidesQuotaBackend) {
                    $quota = $backend->getQuota($uid);
        Severity: Minor
        Found in lib/private/User/SyncService.php - About 35 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 checkIfAccountReappeared has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkIfAccountReappeared(Account $a, array &$removed, array &$reappeared, UserInterface $backend, $backendClass) {
                if ($a->getBackend() === $backendClass) {
                    // Does the backend have this user still
                    if ($backend->userExists($a->getUserId())) {
                        // Is the user not enabled currently?
        Severity: Minor
        Found in lib/private/User/SyncService.php - About 35 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 syncUserName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function syncUserName(Account $a, UserInterface $backend) {
                $uid = $a->getUserId();
                if ($backend instanceof IProvidesUserNameBackend) {
                    $userName = $backend->getUserName($uid);
                    $currentUserName = $this->config->getUserValue($uid, 'core', 'username', null);
        Severity: Minor
        Found in lib/private/User/SyncService.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