owncloud/core

View on GitHub
lib/private/Files/ObjectStore/ObjectStoreStorage.php

Summary

Maintainability
F
3 days
Test Coverage

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

<?php
/**
 * @author Joas Schilling <coding@schilljs.com>
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Morris Jobke <hey@morrisjobke.de>
Severity: Minor
Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 6 hrs to fix

    ObjectStoreStorage has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ObjectStoreStorage extends \OC\Files\Storage\Common {
        /**
         * @var array
         */
        private static $tmpFiles = [];
    Severity: Minor
    Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 3 hrs to fix

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

          public function fopen($path, $mode) {
              $path = $this->normalizePath($path);
      
              switch ($mode) {
                  case 'r':
      Severity: Minor
      Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 1 hr to fix

        Function mkdir has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function mkdir($path) {
                $path = $this->normalizePath($path);
        
                if ($this->file_exists($path)) {
                    return false;
        Severity: Minor
        Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 writeBack has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function writeBack($tmpFile) {
                if (!isset(self::$tmpFiles[$tmpFile])) {
                    return;
                }
        
        
        Severity: Minor
        Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 1 hr to fix

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

              public function mkdir($path) {
                  $path = $this->normalizePath($path);
          
                  if ($this->file_exists($path)) {
                      return false;
          Severity: Minor
          Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 1 hr to fix

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

                public function unlink($path) {
                    $path = $this->normalizePath($path);
                    $stat = $this->stat($path);
            
                    if ($stat && isset($stat['fileid'])) {
            Severity: Minor
            Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function touch($path, $mtime = null) {
                    if ($mtime === null) {
                        $mtime = \time();
                    }
            
            
            Severity: Minor
            Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 1 hr to fix

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

                  public function fopen($path, $mode) {
                      $path = $this->normalizePath($path);
              
                      switch ($mode) {
                          case 'r':
              Severity: Minor
              Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 moveFromStorage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
                      if ($sourceStorage === $this) {
                          return $this->copy($sourceInternalPath, $targetInternalPath);
                      }
                      // cross storage moves need to perform a move operation
              Severity: Minor
              Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 1 hr to fix

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

                    public function touch($path, $mtime = null) {
                        if ($mtime === null) {
                            $mtime = \time();
                        }
                
                
                Severity: Minor
                Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __construct($params) {
                        if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
                            $this->objectStore = $params['objectstore'];
                        } else {
                            throw new \Exception('missing IObjectStore instance');
                Severity: Minor
                Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 writeBack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function writeBack($tmpFile) {
                        if (!isset(self::$tmpFiles[$tmpFile])) {
                            return;
                        }
                
                
                Severity: Minor
                Found in lib/private/Files/ObjectStore/ObjectStoreStorage.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 lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return true;
                  Severity: Major
                  Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php - About 30 mins to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        public function getContentOfVersion($internalPath, $versionId) {
                            if ($this->objectStore instanceof IVersionedObjectStorage) {
                                $stat = $this->stat($internalPath);
                                if ($stat === false) {
                                    throw new NotFoundException();
                    Severity: Minor
                    Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php and 1 other location - About 40 mins to fix
                    lib/private/Files/ObjectStore/ObjectStoreStorage.php on lines 630..639

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 93.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        public function restoreVersion($internalPath, $versionId) {
                            if ($this->objectStore instanceof IVersionedObjectStorage) {
                                $stat = $this->stat($internalPath);
                                if ($stat === false) {
                                    throw new NotFoundException();
                    Severity: Minor
                    Found in lib/private/Files/ObjectStore/ObjectStoreStorage.php and 1 other location - About 40 mins to fix
                    lib/private/Files/ObjectStore/ObjectStoreStorage.php on lines 619..628

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 93.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status