owncloud/core

View on GitHub
apps/dav/lib/Connector/Sabre/File.php

Summary

Maintainability
F
4 days
Test Coverage

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

<?php
/**
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Jakob Sack <mail@jakobsack.de>
Severity: Major
Found in apps/dav/lib/Connector/Sabre/File.php - About 1 day to fix

    Function put has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

        public function put($data) {
            try {
                $exists = $this->fileView->file_exists($this->path);
                if ($this->info && $exists && !$this->info->isUpdateable()) {
                    throw new Forbidden();
    Severity: Minor
    Found in apps/dav/lib/Connector/Sabre/File.php - About 7 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 createFileChunked has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        private function createFileChunked($data) {
            list($path, $name) = \Sabre\Uri\split($this->path);
    
            $info = \OC_FileChunking::decodeName($name);
            if (empty($info)) {
    Severity: Minor
    Found in apps/dav/lib/Connector/Sabre/File.php - About 5 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 put has 138 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function put($data) {
            try {
                $exists = $this->fileView->file_exists($this->path);
                if ($this->info && $exists && !$this->info->isUpdateable()) {
                    throw new Forbidden();
    Severity: Major
    Found in apps/dav/lib/Connector/Sabre/File.php - About 5 hrs to fix

      Method createFileChunked has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function createFileChunked($data) {
              list($path, $name) = \Sabre\Uri\split($this->path);
      
              $info = \OC_FileChunking::decodeName($name);
              if (empty($info)) {
      Severity: Major
      Found in apps/dav/lib/Connector/Sabre/File.php - About 3 hrs to fix

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

            private function emitPreHooks($exists, $path = null) {
                if ($path === null) {
                    $path = $this->path;
                }
                $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
        Severity: Minor
        Found in apps/dav/lib/Connector/Sabre/File.php - About 1 hr to fix

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

              private function convertToSabreException(\Exception $e) {
                  if ($e instanceof FileContentNotAllowedException) {
                      // the file content is not permitted
                      throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
                  }
          Severity: Minor
          Found in apps/dav/lib/Connector/Sabre/File.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 convertToSabreException has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function convertToSabreException(\Exception $e) {
                  if ($e instanceof FileContentNotAllowedException) {
                      // the file content is not permitted
                      throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
                  }
          Severity: Minor
          Found in apps/dav/lib/Connector/Sabre/File.php - About 1 hr to fix

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

                private function emitPreHooks($exists, $path = null) {
                    if ($path === null) {
                        $path = $this->path;
                    }
                    $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
            Severity: Minor
            Found in apps/dav/lib/Connector/Sabre/File.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 get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function get() {
                    //throw exception if encryption is disabled but files are still encrypted
                    try {
                        $viewPath = \ltrim($this->path, '/');
                        if (!$this->info->isReadable() || !$this->fileView->file_exists($viewPath)) {
            Severity: Minor
            Found in apps/dav/lib/Connector/Sabre/File.php - About 35 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 cleanFailedUpload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function cleanFailedUpload(Storage $partStorage, $internalPartPath): void {
                    if ($partStorage->file_exists($internalPartPath)) {
                        try {
                            # broken/uncompleted uploaded files shall not go into trash-bin
                            if (class_exists(\OCA\Files_Trashbin\Storage::class)) {
            Severity: Minor
            Found in apps/dav/lib/Connector/Sabre/File.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