owncloud/core

View on GitHub
apps/files_sharing/lib/External/Manager.php

Summary

Maintainability
D
2 days
Test Coverage

File Manager.php has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
Severity: Minor
Found in apps/files_sharing/lib/External/Manager.php - About 5 hrs to fix

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

    class Manager {
        public const STORAGE = '\OCA\Files_Sharing\External\Storage';
    
        /**
         * @var string
    Severity: Minor
    Found in apps/files_sharing/lib/External/Manager.php - About 2 hrs to fix

      Method addShare has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function addShare($remote, $token, $password, $name, $owner, $accepted = false, $user = null, $remoteId = -1) {
              $user = $user ? $user : $this->uid;
              $accepted = $accepted ? 1 : 0;
              $name = Filesystem::normalizePath('/' . $name);
      
      
      Severity: Minor
      Found in apps/files_sharing/lib/External/Manager.php - About 1 hr to fix

        Function testRemoteUrl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function testRemoteUrl(IClientService $clientService, string $remote) {
                $parsed_host = parse_url($remote, PHP_URL_HOST);
                $parsed_port = parse_url($remote, PHP_URL_PORT);
                if (\is_string($parsed_host)) {
                    $remote = $parsed_host;
        Severity: Minor
        Found in apps/files_sharing/lib/External/Manager.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 testRemoteUrl has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testRemoteUrl(IClientService $clientService, string $remote) {
                $parsed_host = parse_url($remote, PHP_URL_HOST);
                $parsed_port = parse_url($remote, PHP_URL_PORT);
                if (\is_string($parsed_host)) {
                    $remote = $parsed_host;
        Severity: Minor
        Found in apps/files_sharing/lib/External/Manager.php - About 1 hr to fix

          Method removeShare has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function removeShare($mountPoint) {
                  if ($this->uid === null) {
                      throw new NoUserException();
                  }
          
          
          Severity: Minor
          Found in apps/files_sharing/lib/External/Manager.php - About 1 hr to fix

            Method acceptShare has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function acceptShare($id) {
                    $share = $this->getShare($id);
            
                    if ($share) {
                        $mountPoint = $this->getShareRecipientMountPoint($share);
            Severity: Minor
            Found in apps/files_sharing/lib/External/Manager.php - About 1 hr to fix

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

                  public function addShare($remote, $token, $password, $name, $owner, $accepted = false, $user = null, $remoteId = -1) {
              Severity: Major
              Found in apps/files_sharing/lib/External/Manager.php - About 1 hr to fix

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

                        \OCP\IDBConnection                 $connection,
                        \OC\Files\Mount\Manager            $mountManager,
                        \OCP\Files\Storage\IStorageFactory $storageLoader,
                        IManager                           $notificationManager,
                        EventDispatcherInterface           $eventDispatcher,
                Severity: Minor
                Found in apps/files_sharing/lib/External/Manager.php - About 45 mins to fix

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

                      protected function testUrl(IClientService $clientService, string $remote, bool $checkVersion = false, bool $throwConnectException = false): bool {
                          try {
                              $client = $clientService->newClient();
                              $response = \json_decode($client->get(
                                  $remote,
                  Severity: Minor
                  Found in apps/files_sharing/lib/External/Manager.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