owncloud/core

View on GitHub
lib/private/Files/External/Service/StoragesService.php

Summary

Maintainability
D
2 days
Test Coverage

File StoragesService.php has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Jesús Macias <jmacias@solidgear.es>
 * @author Lukas Reschke <lukas@statuscode.ch>
 * @author Robin Appelman <icewind@owncloud.com>
Severity: Minor
Found in lib/private/Files/External/Service/StoragesService.php - About 4 hrs to fix

    Function updateStorage has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function updateStorage(IStorageConfig $updatedStorage) {
            $id = $updatedStorage->getId();
    
            $existingMount = $this->dbConfig->getMountById($id);
    
    
    Severity: Minor
    Found in lib/private/Files/External/Service/StoragesService.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 updateStorage has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function updateStorage(IStorageConfig $updatedStorage) {
            $id = $updatedStorage->getId();
    
            $existingMount = $this->dbConfig->getMountById($id);
    
    
    Severity: Major
    Found in lib/private/Files/External/Service/StoragesService.php - About 2 hrs to fix

      StoragesService has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class StoragesService implements IStoragesService {
          /** @var IStoragesBackendService */
          protected $backendService;
      
          /**
      Severity: Minor
      Found in lib/private/Files/External/Service/StoragesService.php - About 2 hrs to fix

        Method getStorageConfigFromDBMount has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getStorageConfigFromDBMount(array $mount) {
                $applicableUsers = \array_filter($mount['applicable'], function ($applicable) {
                    return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_USER;
                });
                $applicableUsers = \array_map(function ($applicable) {
        Severity: Minor
        Found in lib/private/Files/External/Service/StoragesService.php - About 1 hr to fix

          Method addStorage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function addStorage(IStorageConfig $newStorage) {
                  $allStorages = $this->readConfig();
          
                  $configId = $this->dbConfig->addMount(
                      $newStorage->getMountPoint(),
          Severity: Minor
          Found in lib/private/Files/External/Service/StoragesService.php - About 1 hr to fix

            Method createStorage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function createStorage(
                    $mountPoint,
                    $backendIdentifier,
                    $authMechanismIdentifier,
                    $backendOptions,
            Severity: Minor
            Found in lib/private/Files/External/Service/StoragesService.php - About 1 hr to fix

              Method createStorage has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      $mountPoint,
                      $backendIdentifier,
                      $authMechanismIdentifier,
                      $backendOptions,
                      $mountOptions = null,
              Severity: Major
              Found in lib/private/Files/External/Service/StoragesService.php - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                            return null;
                Severity: Major
                Found in lib/private/Files/External/Service/StoragesService.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $config;
                  Severity: Major
                  Found in lib/private/Files/External/Service/StoragesService.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return null;
                    Severity: Major
                    Found in lib/private/Files/External/Service/StoragesService.php - About 30 mins to fix

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

                          public function createStorage(
                              $mountPoint,
                              $backendIdentifier,
                              $authMechanismIdentifier,
                              $backendOptions,
                      Severity: Minor
                      Found in lib/private/Files/External/Service/StoragesService.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

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

                          private function decryptIfPassword(Backend $backend, AuthMechanism $auth, $key, $value) {
                              $backendParameters = $backend->getParameters();
                              $authParameters = $auth->getParameters();
                              if (
                                  (
                      Severity: Minor
                      Found in lib/private/Files/External/Service/StoragesService.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

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

                          public function addStorage(IStorageConfig $newStorage) {
                              $allStorages = $this->readConfig();
                      
                              $configId = $this->dbConfig->addMount(
                                  $newStorage->getMountPoint(),
                      Severity: Minor
                      Found in lib/private/Files/External/Service/StoragesService.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