owncloud/core

View on GitHub
lib/private/Repair/RepairMismatchFileCachePath.php

Summary

Maintainability
D
1 day
Test Coverage

File RepairMismatchFileCachePath.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Vincent Petry <pvince81@owncloud.com>
 *
 * @copyright Copyright (c) 2018, ownCloud GmbH
Severity: Minor
Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 4 hrs to fix

    Method getOrCreateEntry has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getOrCreateEntry($storageId, $path, $reuseFileId = null) {
            if ($path === '.') {
                $path = '';
            }
            // find the correct parent
    Severity: Major
    Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 2 hrs to fix

      Function getOrCreateEntry has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getOrCreateEntry($storageId, $path, $reuseFileId = null) {
              if ($path === '.') {
                  $path = '';
              }
              // find the correct parent
      Severity: Minor
      Found in lib/private/Repair/RepairMismatchFileCachePath.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 fixEntriesWithCorrectParentIdButWrongPath has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function fixEntriesWithCorrectParentIdButWrongPath(IOutput $out, $storageNumericId = null) {
              $totalResultsCount = 0;
              $affectedStorages = [$storageNumericId => true];
      
              // find all entries where the path entry doesn't match the path value that would
      Severity: Minor
      Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 1 hr to fix

        Method addQueryConditionsParentIdWrongPath has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function addQueryConditionsParentIdWrongPath($qb) {
                // thanks, VicDeo!
                if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
                    $concatFunction = $qb->createFunction("CONCAT(fcp.path, '/', fc.name)");
                } else {
        Severity: Minor
        Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 1 hr to fix

          Method fixEntriesWithNonExistingParentIdEntry has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function fixEntriesWithNonExistingParentIdEntry(IOutput $out, $storageNumericId = null) {
                  $qb = $this->connection->getQueryBuilder();
                  $this->addQueryConditionsNonExistingParentIdEntry($qb, $storageNumericId);
                  $qb->setMaxResults(self::CHUNK_SIZE);
          
          
          Severity: Minor
          Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 1 hr to fix

            Method fixEntryParent has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private function fixEntryParent(IOutput $out, $storageId, $fileId, $path, $wrongParentId, $parentIdExists = false) {
            Severity: Minor
            Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 45 mins to fix

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

                  public function doRepair(IOutput $out) {
                      $this->dirMimeTypeId = $this->mimeLoader->getId('httpd/unix-directory');
                      $this->dirMimePartId = $this->mimeLoader->getId('httpd');
              
                      if ($this->countOnly) {
              Severity: Minor
              Found in lib/private/Repair/RepairMismatchFileCachePath.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 fixEntryPath has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function fixEntryPath(IOutput $out, $fileId, $wrongPath, $correctStorageNumericId, $correctPath) {
              Severity: Minor
              Found in lib/private/Repair/RepairMismatchFileCachePath.php - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status