owncloud/core

View on GitHub
lib/private/Files/Storage/Local.php

Summary

Maintainability
D
2 days
Test Coverage

Local has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

class Local extends Common {
    protected $datadir;

    protected $dataDirLength;

Severity: Minor
Found in lib/private/Files/Storage/Local.php - About 4 hrs to fix

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

    <?php
    /**
     * @author Bart Visscher <bartv@thisnet.nl>
     * @author Boris Rybalkin <ribalkin@gmail.com>
     * @author Brice Maron <brice@bmaron.net>
    Severity: Minor
    Found in lib/private/Files/Storage/Local.php - About 3 hrs to fix

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

          public function rename($path1, $path2) {
              $srcParent = \dirname($path1);
              $dstParent = \dirname($path2);
      
              if (!$this->isUpdatable($srcParent)) {
      Severity: Minor
      Found in lib/private/Files/Storage/Local.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

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

          public function filemtime($path) {
              $fullPath = $this->getSourcePath($path);
              \clearstatcache($fullPath);
              if (!$this->file_exists($path)) {
                  return false;
      Severity: Minor
      Found in lib/private/Files/Storage/Local.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 rename has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function rename($path1, $path2) {
              $srcParent = \dirname($path1);
              $dstParent = \dirname($path2);
      
              if (!$this->isUpdatable($srcParent)) {
      Severity: Minor
      Found in lib/private/Files/Storage/Local.php - About 1 hr to fix

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

            public function rmdir($path) {
                if (!$this->isDeletable($path)) {
                    return false;
                }
                try {
        Severity: Minor
        Found in lib/private/Files/Storage/Local.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

        Function getSourcePath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSourcePath($path) {
                $fullPath = $this->datadir . $path;
                if ($this->allowSymlinks || $path === '') {
                    return $fullPath;
                }
        Severity: Minor
        Found in lib/private/Files/Storage/Local.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

        Function searchInDir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function searchInDir($query, $dir = '') {
                $files = [];
                $physicalDir = $this->getSourcePath($dir);
                foreach (\scandir($physicalDir) as $item) {
                    if (\OC\Files\Filesystem::isIgnoredDir($item)) {
        Severity: Minor
        Found in lib/private/Files/Storage/Local.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 \rename($this->getSourcePath($path1), $this->getSourcePath($path2));
        Severity: Major
        Found in lib/private/Files/Storage/Local.php - About 30 mins to fix

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

              public function touch($path, $mtime = null) {
                  // sets the modification time of the file to the given value.
                  // If mtime is nil the current time is set.
                  // note that the access time of the file always changes to the current time.
                  if ($this->file_exists($path) and !$this->isUpdatable($path)) {
          Severity: Minor
          Found in lib/private/Files/Storage/Local.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