rene-s/Seafile-PHP-SDK

View on GitHub

Showing 18 of 18 total issues

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

<?php

namespace Seafile\Client\Resource;

use Exception;
Severity: Minor
Found in src/Resource/File.php - About 3 hrs to fix

    Method create has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function create(
            LibraryType           $library,
            string                $path,
            SharedLinkPermissions $permissions,
            int                   $expire = null,
    Severity: Major
    Found in src/Resource/ShareLinks.php - About 2 hrs to fix

      Method create has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create(LibraryType $library, string $dirName, string $parentDir = '/', bool $recursive = false)
          {
              if ($recursive) {
                  $response = false;
                  $parts = explode('/', trim($dirName, '/'));
      Severity: Minor
      Found in src/Resource/Directory.php - About 1 hr to fix

        Method copy has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function copy(
                LibraryType $srcLibrary,
                array       $srcPaths,
                LibraryType $dstLibrary,
                string      $dstDirectoryPath,
        Severity: Minor
        Found in src/Resource/Multi.php - About 1 hr to fix

          Method copy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function copy(
                  LibraryType $srcLibrary,
                  string      $srcFilePath,
                  LibraryType $dstLibrary,
                  string      $dstDirectoryPath,
          Severity: Minor
          Found in src/Resource/File.php - About 1 hr to fix

            Method create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function create($name, $description = "new repo", $password = ''): bool
                {
                    // only create a library which is not empty to prevent wrong implementation
                    if (empty($name)) {
                        return false;
            Severity: Minor
            Found in src/Resource/Library.php - About 1 hr to fix

              Method rename has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function rename(LibraryType $library, DirectoryItem $dirItem, string $newFilename): bool
                  {
                      $filePath = $dirItem->dir . $dirItem->name;
              
                      if (empty($filePath)) {
              Severity: Minor
              Found in src/Resource/File.php - About 1 hr to fix

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

                    public function getMultiPartParams(
                        string $localFilePath,
                        string $dir,
                        bool   $newFile = true,
                               $newFilename = false
                Severity: Minor
                Found in src/Resource/File.php - About 1 hr to fix

                  Method delete has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function delete(LibraryType $library, array $paths): bool
                      {
                          // do not allow empty paths
                          if (empty($paths)) {
                              return false;
                  Severity: Minor
                  Found in src/Resource/Multi.php - About 1 hr to fix

                    Method rename has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function rename(LibraryType $library, string $directoryPath, string $newDirectoryName)
                        {
                            // don't allow empty paths
                            if (empty($directoryPath) || empty($newDirectoryName)) {
                                return false;
                    Severity: Minor
                    Found in src/Resource/Directory.php - About 1 hr to fix

                      Function fromArray has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function fromArray(array $fromArray) // type is given in derived class
                          {
                              foreach ($fromArray as $key => $value) {
                                  $camelCaseKey = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_SNAKE_CASE)->toCamelCase($key);
                      
                      
                      Severity: Minor
                      Found in src/Type/Type.php - About 55 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function create(LibraryType $library, string $dirName, string $parentDir = '/', bool $recursive = false)
                          {
                              if ($recursive) {
                                  $response = false;
                                  $parts = explode('/', trim($dirName, '/'));
                      Severity: Minor
                      Found in src/Resource/Directory.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 create has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              LibraryType           $library,
                              string                $path,
                              SharedLinkPermissions $permissions,
                              int                   $expire = null,
                              string                $password = null
                      Severity: Minor
                      Found in src/Resource/ShareLinks.php - About 35 mins to fix

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

                                LibraryType   $library,
                                DirectoryItem $item,
                                string        $localFilePath,
                                string        $dir,
                                int           $reuse = 1
                        Severity: Minor
                        Found in src/Resource/File.php - About 35 mins to fix

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

                                  LibraryType $srcLibrary,
                                  array       $srcPaths,
                                  LibraryType $dstLibrary,
                                  string      $dstDirectoryPath,
                                  int         $operation = self::OPERATION_COPY
                          Severity: Minor
                          Found in src/Resource/Multi.php - About 35 mins to fix

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

                                    LibraryType $library,
                                    string      $localFilePath,
                                    string      $dir = '/',
                                                $newFilename = false,
                                    bool        $newFile = true
                            Severity: Minor
                            Found in src/Resource/File.php - About 35 mins to fix

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

                                      LibraryType $srcLibrary,
                                      string      $srcFilePath,
                                      LibraryType $dstLibrary,
                                      string      $dstDirectoryPath,
                                      int         $operation = self::OPERATION_COPY
                              Severity: Minor
                              Found in src/Resource/File.php - About 35 mins to fix

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

                                    public function toArray(int $mode = self::ARRAY_ASSOC): array
                                    {
                                        switch ($mode) {
                                            case self::ARRAY_MULTI_PART:
                                                $caseHelper = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_CAMEL_CASE);
                                Severity: Minor
                                Found in src/Type/Type.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

                                Severity
                                Category
                                Status
                                Source
                                Language