owncloud/core

View on GitHub
lib/private/Files/Cache/Scanner.php

Summary

Maintainability
F
3 days
Test Coverage

Function scanFile has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

    public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
        // only proceed if $file is not a partial file nor a blacklisted file
        if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file)) {
            //acquire a lock
            if ($lock && $this->storage->instanceOfStorage(ILockingStorage::class)) {
Severity: Minor
Found in lib/private/Files/Cache/Scanner.php - About 1 day 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 scanFile has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
        // only proceed if $file is not a partial file nor a blacklisted file
        if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file)) {
            //acquire a lock
            if ($lock && $this->storage->instanceOfStorage(ILockingStorage::class)) {
Severity: Major
Found in lib/private/Files/Cache/Scanner.php - About 3 hrs to fix

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

    <?php
    /**
     * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
     * @author Björn Schießle <bjoern@schiessle.org>
     * @author Daniel Jagszent <daniel@jagszent.de>
    Severity: Minor
    Found in lib/private/Files/Cache/Scanner.php - About 3 hrs to fix

      Function handleChildren has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private function handleChildren($path, $recursive, $reuse, $folderId, $lock, &$size) {
              // we put this in it's own function so it cleans up the memory before we start recursing
              $existingChildren = $this->getExistingChildren($folderId);
              $newChildren = $this->getNewChildren($path);
      
      
      Severity: Minor
      Found in lib/private/Files/Cache/Scanner.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 handleChildren has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function handleChildren($path, $recursive, $reuse, $folderId, $lock, &$size) {
              // we put this in it's own function so it cleans up the memory before we start recursing
              $existingChildren = $this->getExistingChildren($folderId);
              $newChildren = $this->getNewChildren($path);
      
      
      Severity: Minor
      Found in lib/private/Files/Cache/Scanner.php - About 1 hr to fix

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

            protected function getNewChildren($folder) {
                $children = [];
                if ($dh = $this->storage->opendir($folder)) {
                    if (\is_resource($dh)) {
                        while (($file = \readdir($dh)) !== false) {
        Severity: Minor
        Found in lib/private/Files/Cache/Scanner.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 scanChildren has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true) {
                if ($reuse === -1) {
                    $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
                }
                $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', [$path, $this->storageId]);
        Severity: Minor
        Found in lib/private/Files/Cache/Scanner.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 handleChildren has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function handleChildren($path, $recursive, $reuse, $folderId, $lock, &$size) {
        Severity: Minor
        Found in lib/private/Files/Cache/Scanner.php - About 45 mins to fix

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

              public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
          Severity: Minor
          Found in lib/private/Files/Cache/Scanner.php - About 35 mins to fix

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

                protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true) {
            Severity: Minor
            Found in lib/private/Files/Cache/Scanner.php - About 35 mins to fix

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

                  public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
                      if ($reuse === -1) {
                          $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
                      }
                      if ($lock && $this->storage->instanceOfStorage(ILockingStorage::class)) {
              Severity: Minor
              Found in lib/private/Files/Cache/Scanner.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 runBackgroundScanJob has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function runBackgroundScanJob(callable $callback, $path) {
                      try {
                          $callback();
                          \OC_Hook::emit('Scanner', 'correctFolderSize', ['path' => $path]);
                          if ($this->cacheActive && $this->cache instanceof Cache) {
              Severity: Minor
              Found in lib/private/Files/Cache/Scanner.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