owncloud/core

View on GitHub
lib/private/Updater.php

Summary

Maintainability
C
1 day
Test Coverage

Function doAppUpgrade has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doAppUpgrade() {
        $apps = \OC_App::getEnabledApps();
        $priorityTypes = ['authentication', 'filesystem', 'logging'];
        $pseudoOtherType = 'other';
        $stacks = [$pseudoOtherType => []];
Severity: Minor
Found in lib/private/Updater.php - About 2 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 doUpgrade has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function doUpgrade($currentVersion, $installedVersion) {
        // Stop update if the update is over several major versions
        $allowedPreviousVersions = $this->getAllowedPreviousVersions();
        if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
            throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
Severity: Minor
Found in lib/private/Updater.php - About 1 hr to fix

    Method doAppUpgrade has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function doAppUpgrade() {
            $apps = \OC_App::getEnabledApps();
            $priorityTypes = ['authentication', 'filesystem', 'logging'];
            $pseudoOtherType = 'other';
            $stacks = [$pseudoOtherType => []];
    Severity: Minor
    Found in lib/private/Updater.php - About 1 hr to fix

      Method upgrade has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function upgrade() {
              $this->emitRepairEvents();
      
              $logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
              $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
      Severity: Minor
      Found in lib/private/Updater.php - About 1 hr to fix

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

            public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersions) {
                // TODO: write tests for this, since i just wrapped it to get started with migrations and this might fail in some cases
                foreach ($allowedPreviousVersions as $allowedPreviousVersion) {
                    $allowedUpgrade =  (\version_compare($allowedPreviousVersion, $oldVersion, '<=')
                        && (\version_compare($oldVersion, $newVersion, '<=') || $this->config->getSystemValue('debug', false)));
        Severity: Minor
        Found in lib/private/Updater.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 doUpgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function doUpgrade($currentVersion, $installedVersion) {
                // Stop update if the update is over several major versions
                $allowedPreviousVersions = $this->getAllowedPreviousVersions();
                if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
                    throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
        Severity: Minor
        Found in lib/private/Updater.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

        There are no issues that match your filters.

        Category
        Status