owncloud/core

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

Summary

Maintainability
F
3 days
Test Coverage

Common has 61 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Common implements Storage, ILockingStorage, IVersionedStorage, IPersistentLockingStorage {
    use LocalTempFileTrait;

    protected $cache;
    protected $scanner;
Severity: Major
Found in lib/private/Files/Storage/Common.php - About 1 day to fix

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

    <?php
    /**
     * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
     * @author Bart Visscher <bartv@thisnet.nl>
     * @author Björn Schießle <bjoern@schiessle.org>
    Severity: Major
    Found in lib/private/Files/Storage/Common.php - About 1 day to fix

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

          public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
              if ($sourceStorage === $this) {
                  return $this->copy($sourceInternalPath, $targetInternalPath);
              }
      
      
      Severity: Minor
      Found in lib/private/Files/Storage/Common.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

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

          protected function searchInDir($query, $dir = '') {
              $files = [];
              $dh = $this->opendir($dir);
              if (\is_resource($dh)) {
                  while (($item = \readdir($dh)) !== false) {
      Severity: Minor
      Found in lib/private/Files/Storage/Common.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 copy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function copy($path1, $path2) {
              if ($this->is_dir($path1)) {
                  $this->remove($path2);
                  $dir = $this->opendir($path1);
                  $this->mkdir($path2);
      Severity: Minor
      Found in lib/private/Files/Storage/Common.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 addLocalFolder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function addLocalFolder($path, $target) {
              $dh = $this->opendir($path);
              if (\is_resource($dh)) {
                  while (($file = \readdir($dh)) !== false) {
                      if (!Filesystem::isIgnoredDir($file)) {
      Severity: Minor
      Found in lib/private/Files/Storage/Common.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 copyFromStorage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
              if ($sourceStorage === $this) {
                  return $this->copy($sourceInternalPath, $targetInternalPath);
              }
      
      
      Severity: Minor
      Found in lib/private/Files/Storage/Common.php - About 1 hr to fix

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

            public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
                if ($sourceStorage === $this) {
                    return $this->rename($sourceInternalPath, $targetInternalPath);
                }
        
        
        Severity: Minor
        Found in lib/private/Files/Storage/Common.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 cleanPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function cleanPath($path) {
                if (\strlen($path) == 0 or $path[0] != '/') {
                    $path = '/' . $path;
                }
        
        
        Severity: Minor
        Found in lib/private/Files/Storage/Common.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