owncloud/core

View on GitHub
lib/private/SystemTag/SystemTagManager.php

Summary

Maintainability
D
2 days
Test Coverage

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

<?php
/**
 * @author Joas Schilling <coding@schilljs.com>
 * @author Vincent Petry <pvince81@owncloud.com>
 *
Severity: Minor
Found in lib/private/SystemTag/SystemTagManager.php - About 4 hrs to fix

    Method updateTag has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function updateTag($tagId, $tagName, $userVisible, $userAssignable, $userEditable = null) {
            $userVisible = (int)$userVisible;
            $userAssignable = (int)$userAssignable;
    
            /**
    Severity: Major
    Found in lib/private/SystemTag/SystemTagManager.php - About 2 hrs to fix

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

          public function createTag($tagName, $userVisible, $userAssignable, $userEditable = null) {
              $userVisible = (int)$userVisible;
              $userAssignable = (int)$userAssignable;
      
              /**
      Severity: Minor
      Found in lib/private/SystemTag/SystemTagManager.php - About 1 hr to fix

        Method deleteTags has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function deleteTags($tagIds) {
                if (!\is_array($tagIds)) {
                    $tagIds = [$tagIds];
                }
        
        
        Severity: Minor
        Found in lib/private/SystemTag/SystemTagManager.php - About 1 hr to fix

          Method getTagsByIds has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getTagsByIds($tagIds) {
                  if (!\is_array($tagIds)) {
                      $tagIds = [$tagIds];
                  }
          
          
          Severity: Minor
          Found in lib/private/SystemTag/SystemTagManager.php - About 1 hr to fix

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

                public function getAllTags($visibilityFilter = null, $nameSearchPattern = null) {
                    $tags = [];
            
                    $query = $this->connection->getQueryBuilder();
                    $query->select('*')
            Severity: Minor
            Found in lib/private/SystemTag/SystemTagManager.php - About 1 hr to fix

              Function deleteTags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function deleteTags($tagIds) {
                      if (!\is_array($tagIds)) {
                          $tagIds = [$tagIds];
                      }
              
              
              Severity: Minor
              Found in lib/private/SystemTag/SystemTagManager.php - About 55 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 updateTag has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function updateTag($tagId, $tagName, $userVisible, $userAssignable, $userEditable = null) {
              Severity: Minor
              Found in lib/private/SystemTag/SystemTagManager.php - About 35 mins to fix

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

                    public function canUserAssignTag(ISystemTag $tag, IUser $user) {
                        // early check to avoid unneeded group lookups
                        if ($tag->isUserAssignable() && $tag->isUserVisible()) {
                            return true;
                        }
                Severity: Minor
                Found in lib/private/SystemTag/SystemTagManager.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 canUserUseStaticTagInGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function canUserUseStaticTagInGroup(ISystemTag $tag, IUser $user) {
                        if ($this->groupManager->isAdmin($user->getUID())) {
                            return true;
                        }
                        if ($tag->isUserEditable() === false) {
                Severity: Minor
                Found in lib/private/SystemTag/SystemTagManager.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 false;
                Severity: Major
                Found in lib/private/SystemTag/SystemTagManager.php - About 30 mins to fix

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

                      public function getTagsByIds($tagIds) {
                          if (!\is_array($tagIds)) {
                              $tagIds = [$tagIds];
                          }
                  
                  
                  Severity: Minor
                  Found in lib/private/SystemTag/SystemTagManager.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