owncloud/core

View on GitHub
lib/private/legacy/helper.php

Summary

Maintainability
D
2 days
Test Coverage

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

<?php
/**
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Björn Schießle <bjoern@schiessle.org>
Severity: Minor
Found in lib/private/legacy/helper.php - About 5 hrs to fix

    OC_Helper has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OC_Helper {
        private static $templateManager;
    
        /**
         * Creates an absolute url for public use
    Severity: Minor
    Found in lib/private/legacy/helper.php - About 2 hrs to fix

      Method getStorageInfo has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getStorageInfo($path, $rootInfo = null) {
              // return storage info without adding mount points
              $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
      
              if (!$rootInfo) {
      Severity: Major
      Found in lib/private/legacy/helper.php - About 2 hrs to fix

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

            public static function getStorageInfo($path, $rootInfo = null) {
                // return storage info without adding mount points
                $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
        
                if (!$rootInfo) {
        Severity: Minor
        Found in lib/private/legacy/helper.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

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

            public static function rmdirr($dir, $deleteSelf = true) {
                if (\is_dir($dir)) {
                    $files = new RecursiveIteratorIterator(
                        new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
                        RecursiveIteratorIterator::CHILD_FIRST
        Severity: Minor
        Found in lib/private/legacy/helper.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 buildNotExistingFileNameForView has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function buildNotExistingFileNameForView($path, $filename, \OC\Files\View $view) {
                if ($path === '/') {
                    $path = '';
                }
                if ($pos = \strrpos($filename, '.')) {
        Severity: Minor
        Found in lib/private/legacy/helper.php - About 1 hr to fix

          Function buildNotExistingFileNameForView has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function buildNotExistingFileNameForView($path, $filename, \OC\Files\View $view) {
                  if ($path === '/') {
                      $path = '';
                  }
                  if ($pos = \strrpos($filename, '.')) {
          Severity: Minor
          Found in lib/private/legacy/helper.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

          Function copyr has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function copyr($src, $dest) {
                  if (\is_dir($src)) {
                      if (!\is_dir($dest)) {
                          \mkdir($dest);
                      }
          Severity: Minor
          Found in lib/private/legacy/helper.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

          Function canExecute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function canExecute($name, $path = false) {
                  // path defaults to PATH from environment if not set
                  if ($path === false) {
                      $path = \getenv("PATH");
                  }
          Severity: Minor
          Found in lib/private/legacy/helper.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 rmdirr has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function rmdirr($dir, $deleteSelf = true) {
                  if (\is_dir($dir)) {
                      $files = new RecursiveIteratorIterator(
                          new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
                          RecursiveIteratorIterator::CHILD_FIRST
          Severity: Minor
          Found in lib/private/legacy/helper.php - About 1 hr to fix

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

                public static function streamCopy($source, $target) {
                    if (!$source or !$target) {
                        return [0, false];
                    }
                    $bufSize = 8192;
            Severity: Minor
            Found in lib/private/legacy/helper.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

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

                public static function findBinaryPath($program) {
                    $memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
                    if ($memcache->hasKey($program)) {
                        return $memcache->get($program);
                    }
            Severity: Minor
            Found in lib/private/legacy/helper.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 "$bytes TB";
            Severity: Major
            Found in lib/private/legacy/helper.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return "$bytes PB";
              Severity: Major
              Found in lib/private/legacy/helper.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $bytes . "G";
                Severity: Major
                Found in lib/private/legacy/helper.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return "$bytes GB";
                  Severity: Major
                  Found in lib/private/legacy/helper.php - About 30 mins to fix

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

                        public static function humanFileSize($bytes) {
                            if ($bytes < 0) {
                                return "?";
                            }
                            if ($bytes < 1024) {
                    Severity: Minor
                    Found in lib/private/legacy/helper.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 getGlobalStorageInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static function getGlobalStorageInfo() {
                            $quota = OC_Util::getUserQuota(\OCP\User::getUser());
                    
                            $rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
                            $used = $rootInfo['size'];
                    Severity: Minor
                    Found in lib/private/legacy/helper.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