owncloud/core

View on GitHub
apps/files_external/lib/Lib/Storage/Google.php

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php
/**
 * @author Adam Williamson <awilliam@redhat.com>
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Bart Visscher <bartv@thisnet.nl>
Severity: Major
Found in apps/files_external/lib/Lib/Storage/Google.php - About 1 day to fix

    Function opendir has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        public function opendir($path) {
            $folder = $this->getDriveFile($path);
            if ($folder) {
                $files = [];
                $duplicates = [];
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/Google.php - About 6 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

    Function getInternalDriveFile has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getInternalDriveFile($path) {
            // Remove leading and trailing slashes
            $path = \trim($path, '/');
            if ($path === '.') {
                $path = '';
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/Google.php - About 5 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

    Function writeBack has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function writeBack($tmpFile) {
            if (isset(self::$tempFiles[$tmpFile])) {
                $path = self::$tempFiles[$tmpFile];
                $parentFolder = $this->getDriveFile(\dirname($path));
                if ($parentFolder) {
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/Google.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

    Google has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Google extends \OCP\Files\Storage\StorageAdapter {
        private $client;
        private $id;
        private $root;
        private $service;
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/Google.php - About 3 hrs to fix

      Function rename has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public function rename($path1, $path2) {
              $file = $this->getDriveFile($path1);
              if ($file) {
                  $newFile = $this->getDriveFile($path2);
                  $toUpdate = new DriveFile();
      Severity: Minor
      Found in apps/files_external/lib/Lib/Storage/Google.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

      Function fopen has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function fopen($path, $mode) {
              $pos = \strrpos($path, '.');
              if ($pos !== false) {
                  $ext = \substr($path, $pos);
              } else {
      Severity: Minor
      Found in apps/files_external/lib/Lib/Storage/Google.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 writeBack has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function writeBack($tmpFile) {
              if (isset(self::$tempFiles[$tmpFile])) {
                  $path = self::$tempFiles[$tmpFile];
                  $parentFolder = $this->getDriveFile(\dirname($path));
                  if ($parentFolder) {
      Severity: Major
      Found in apps/files_external/lib/Lib/Storage/Google.php - About 2 hrs to fix

        Method getInternalDriveFile has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getInternalDriveFile($path) {
                // Remove leading and trailing slashes
                $path = \trim($path, '/');
                if ($path === '.') {
                    $path = '';
        Severity: Major
        Found in apps/files_external/lib/Lib/Storage/Google.php - About 2 hrs to fix

          Function rmdir has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function rmdir($path) {
                  if (!$this->isDeletable($path)) {
                      return false;
                  }
                  if (\trim($path, '/') === '') {
          Severity: Minor
          Found in apps/files_external/lib/Lib/Storage/Google.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 fopen has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function fopen($path, $mode) {
                  $pos = \strrpos($path, '.');
                  if ($pos !== false) {
                      $ext = \substr($path, $pos);
                  } else {
          Severity: Major
          Found in apps/files_external/lib/Lib/Storage/Google.php - About 2 hrs to fix

            Method opendir has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function opendir($path) {
                    $folder = $this->getDriveFile($path);
                    if ($folder) {
                        $files = [];
                        $duplicates = [];
            Severity: Minor
            Found in apps/files_external/lib/Lib/Storage/Google.php - About 2 hrs to fix

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

                  public function rename($path1, $path2) {
                      $file = $this->getDriveFile($path1);
                      if ($file) {
                          $newFile = $this->getDriveFile($path2);
                          $toUpdate = new DriveFile();
              Severity: Minor
              Found in apps/files_external/lib/Lib/Storage/Google.php - About 1 hr to fix

                Function hasUpdated has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function hasUpdated($path, $time) {
                        if ($this->is_file($path)) {
                            return parent::hasUpdated($path, $time);
                        }
                
                
                Severity: Minor
                Found in apps/files_external/lib/Lib/Storage/Google.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 touch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function touch($path, $mtime = null) {
                        $file = $this->getDriveFile($path);
                        $toUpdate = new DriveFile();
                        $result = false;
                        if ($file) {
                Severity: Minor
                Found in apps/files_external/lib/Lib/Storage/Google.php - About 1 hr to fix

                  Method hasUpdated has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function hasUpdated($path, $time) {
                          if ($this->is_file($path)) {
                              return parent::hasUpdated($path, $time);
                          }
                  
                  
                  Severity: Minor
                  Found in apps/files_external/lib/Lib/Storage/Google.php - About 1 hr to fix

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

                        public function getMimeType($path) {
                            $file = $this->getDriveFile($path);
                            if ($file) {
                                $mimetype = $file->getMimeType();
                                // Convert Google Doc mimetypes, choosing Open Document formats for download
                    Severity: Minor
                    Found in apps/files_external/lib/Lib/Storage/Google.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 filetype has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function filetype($path) {
                            if ($this->getAbsolutePath($path) === '') {
                                return 'dir';
                            } else {
                                $file = $this->getDriveFile($path);
                    Severity: Minor
                    Found in apps/files_external/lib/Lib/Storage/Google.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 touch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function touch($path, $mtime = null) {
                            $file = $this->getDriveFile($path);
                            $toUpdate = new DriveFile();
                            $result = false;
                            if ($file) {
                    Severity: Minor
                    Found in apps/files_external/lib/Lib/Storage/Google.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

                    Avoid too many return statements within this method.
                    Open

                            return false;
                    Severity: Major
                    Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                                  return false;
                      Severity: Major
                      Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return false;
                        Severity: Major
                        Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this->driveFiles[$path];
                          Severity: Major
                          Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return '';
                            Severity: Major
                            Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return 'application/pdf';
                              Severity: Major
                              Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return false;
                                Severity: Major
                                Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return parent::getMimeType($path);
                                  Severity: Major
                                  Found in apps/files_external/lib/Lib/Storage/Google.php - About 30 mins to fix

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

                                        private function setDriveFileHelper($path, $file) {
                                            $path = \trim($path, '/');
                                            $this->driveFiles[$path] = $file;
                                            if ($file === false) {
                                                // Remove all children
                                    Severity: Minor
                                    Found in apps/files_external/lib/Lib/Storage/Google.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 mkdir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function mkdir($path) {
                                            if (!$this->is_dir($path)) {
                                                $parentFolder = $this->getDriveFile(\dirname($path));
                                                if ($parentFolder) {
                                                    $folder = new DriveFile();
                                    Severity: Minor
                                    Found in apps/files_external/lib/Lib/Storage/Google.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