owncloud/core

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

Summary

Maintainability
D
2 days
Test Coverage

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

<?php
/**
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Lukas Reschke <lukas@statuscode.ch>
Severity: Minor
Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 3 hrs to fix

    Method handleGetProperties has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
            $httpRequest = $this->server->httpRequest;
    
            if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
                if (!$node->getFileInfo()->isReadable()) {
    Severity: Major
    Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 3 hrs to fix

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

          public function httpGet(RequestInterface $request, ResponseInterface $response) {
              // Only handle valid files
              $node = $this->tree->getNodeForPath($request->getPath());
              if (!($node instanceof IFile)) {
                  return;
      Severity: Minor
      Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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 httpGet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function httpGet(RequestInterface $request, ResponseInterface $response) {
              // Only handle valid files
              $node = $this->tree->getNodeForPath($request->getPath());
              if (!($node instanceof IFile)) {
                  return;
      Severity: Minor
      Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 1 hr to fix

        Method initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function initialize(\Sabre\DAV\Server $server) {
                $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
                $server->protectedProperties[] = self::FILEID_PROPERTYNAME;
                $server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME;
                $server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
        Severity: Minor
        Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 1 hr to fix

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

                  Tree $tree,
                  IConfig $config,
                  IRequest $request,
                  $isPublic = false,
                  $downloadAttachment = true
          Severity: Minor
          Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 35 mins to fix

            Function sendFileIdHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) {
                    // chunked upload handling
                    if (\OC_FileChunking::isWebdavChunk()) {
                        list($path, $name) = \Sabre\Uri\split($filePath);
                        $info = \OC_FileChunking::decodeName($name);
            Severity: Minor
            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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

            Avoid too many return statements within this method.
            Open

                                return null;
            Severity: Major
            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return new ChecksumList($checksum);
              Severity: Major
              Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return \OC::$server->getURLGenerator()
                                    ->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileId' => $node->getInternalFileId()]);
                Severity: Major
                Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return null;
                  Severity: Major
                  Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $node->getETag();
                    Severity: Major
                    Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $displayName;
                      Severity: Major
                      Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $node->getSize();
                        Severity: Major
                        Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return false;
                          Severity: Major
                          Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return false;
                            Severity: Major
                            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return $owner->getUID();
                              Severity: Major
                              Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return $this->config->getSystemValue('data-fingerprint', '');
                                Severity: Major
                                Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return false;
                                  Severity: Major
                                  Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                            return $directDownloadUrl['url'];
                                    Severity: Major
                                    Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return true;
                                      Severity: Major
                                      Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return false;
                                        Severity: Major
                                        Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return $node->getSize();
                                          Severity: Major
                                          Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 30 mins to fix

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

                                                public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
                                                    $httpRequest = $this->server->httpRequest;
                                            
                                                    if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
                                                        if (!$node->getFileInfo()->isReadable()) {
                                            Severity: Minor
                                            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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 checkPropFind has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function checkPropFind($request) {
                                                    $path = $request->getPath();
                                                    $node = $this->server->tree->getNodeForPath($path);
                                            
                                                    if ($node instanceof Node) {
                                            Severity: Minor
                                            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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 checkMove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function checkMove($source, $destination) {
                                                    $sourceNode = $this->tree->getNodeForPath($source);
                                                    if (!$sourceNode instanceof Node) {
                                                        return;
                                                    }
                                            Severity: Minor
                                            Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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