owncloud/core

View on GitHub
apps/dav/lib/SystemTag/SystemTagPlugin.php

Summary

Maintainability
C
1 day
Test Coverage

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

    private function createTag($data, $contentType = 'application/json'): ISystemTag {
        if (\explode(';', $contentType)[0] === 'application/json') {
            $data = \json_decode($data, true);
        } else {
            throw new UnsupportedMediaType();
Severity: Minor
Found in apps/dav/lib/SystemTag/SystemTagPlugin.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 handleUpdateProperties has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handleUpdateProperties($path, PropPatch $propPatch) {
        $node = $this->server->tree->getNodeForPath($path);
        if (!($node instanceof SystemTagNode)) {
            return;
        }
Severity: Minor
Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 1 hr to fix

    Method createTag has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function createTag($data, $contentType = 'application/json'): ISystemTag {
            if (\explode(';', $contentType)[0] === 'application/json') {
                $data = \json_decode($data, true);
            } else {
                throw new UnsupportedMediaType();
    Severity: Minor
    Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 1 hr to fix

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

          public function handleGetProperties(
              PropFind $propFind,
              \Sabre\DAV\INode $node
          ) {
              if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
      Severity: Minor
      Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 1 hr to fix

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

            public function httpPost(RequestInterface $request, ResponseInterface $response) {
                $path = $request->getPath();
        
                // Making sure the node exists
                $node = $this->server->tree->getNodeForPath($path);
        Severity: Minor
        Found in apps/dav/lib/SystemTag/SystemTagPlugin.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 $this->tagManager->canUserUseStaticTagInGroup($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
        Severity: Major
        Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $node->getSystemTag()->isUserEditable() ? 'true' : 'false';
          Severity: Major
          Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
            Severity: Major
            Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
              Severity: Major
              Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return \implode('|', $groups);
                Severity: Major
                Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status