owncloud/core

View on GitHub
lib/kernel.php

Summary

Maintainability
F
6 days
Test Coverage

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

<?php
/**
 * @author Adam Williamson <awilliam@redhat.com>
 * @author Andreas Fischer <bantu@owncloud.com>
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
Severity: Major
Found in lib/kernel.php - About 1 day to fix

    Method init has 179 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function init() {
            // calculate the root directories
            OC::$SERVERROOT = \str_replace("\\", '/', \substr(__DIR__, 0, -4));
    
            // register autoloader
    Severity: Major
    Found in lib/kernel.php - About 7 hrs to fix

      Function init has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function init() {
              // calculate the root directories
              OC::$SERVERROOT = \str_replace("\\", '/', \substr(__DIR__, 0, -4));
      
              // register autoloader
      Severity: Minor
      Found in lib/kernel.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

      Function initPaths has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function initPaths() {
              if (\defined('PHPUNIT_CONFIG_DIR')) {
                  self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
              } elseif (\defined('PHPUNIT_RUN') and PHPUNIT_RUN and \is_dir(OC::$SERVERROOT . '/tests/config/')) {
                  self::$configDir = OC::$SERVERROOT . '/tests/config/';
      Severity: Minor
      Found in lib/kernel.php - About 4 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 handleRequest has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function handleRequest() {
              \OC::$server->getEventLogger()->start('handle_request', 'Handle request');
              $systemConfig = \OC::$server->getSystemConfig();
              // load all the classpaths from the enabled apps so they are available
              // in the routing files of each app
      Severity: Minor
      Found in lib/kernel.php - About 3 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 handleRequest has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function handleRequest() {
              \OC::$server->getEventLogger()->start('handle_request', 'Handle request');
              $systemConfig = \OC::$server->getSystemConfig();
              // load all the classpaths from the enabled apps so they are available
              // in the routing files of each app
      Severity: Major
      Found in lib/kernel.php - About 3 hrs to fix

        Method initPaths has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function initPaths() {
                if (\defined('PHPUNIT_CONFIG_DIR')) {
                    self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
                } elseif (\defined('PHPUNIT_RUN') and PHPUNIT_RUN and \is_dir(OC::$SERVERROOT . '/tests/config/')) {
                    self::$configDir = OC::$SERVERROOT . '/tests/config/';
        Severity: Major
        Found in lib/kernel.php - About 3 hrs to fix

          OC has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class OC {
              /**
               * Associative array for autoloading. classname => filename
               */
              public static $CLASSPATH = [];
          Severity: Minor
          Found in lib/kernel.php - About 2 hrs to fix

            Method printUpgradePage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function printUpgradePage() {
                    $systemConfig = \OC::$server->getSystemConfig();
            
                    $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false);
                    $tooBig = false;
            Severity: Minor
            Found in lib/kernel.php - About 1 hr to fix

              Method crashLog has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function crashLog(\Throwable $ex): void {
                      $crashDir = self::$SERVERROOT . '/data';
                      if (self::$config) {
                          $dataDir = self::$config->getValue('datadirectory', self::$SERVERROOT . '/data');
                          $crashDir = self::$config->getValue('crashdirectory', $dataDir);
              Severity: Minor
              Found in lib/kernel.php - About 1 hr to fix

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

                    public static function initSession() {
                        // Let the session name be changed in the initSession Hook
                        $sessionName = OC_Util::getInstanceId();
                
                        try {
                Severity: Minor
                Found in lib/kernel.php - About 1 hr to fix

                  Function initSession has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function initSession() {
                          // Let the session name be changed in the initSession Hook
                          $sessionName = OC_Util::getInstanceId();
                  
                          try {
                  Severity: Minor
                  Found in lib/kernel.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 checkConfig has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function checkConfig() {
                          $l = \OC::$server->getL10N('lib');
                  
                          // Create config if it does not already exist
                          $configFilePath = self::$configDir .'/config.php';
                  Severity: Minor
                  Found in lib/kernel.php - About 1 hr to fix

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

                        public static function checkConfig() {
                            $l = \OC::$server->getL10N('lib');
                    
                            // Create config if it does not already exist
                            $configFilePath = self::$configDir .'/config.php';
                    Severity: Minor
                    Found in lib/kernel.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 checkSingleUserMode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function checkSingleUserMode($lockIfNoUserLoggedIn = false) {
                            if (!\OC::$server->getSystemConfig()->getValue('singleuser', false)) {
                                return;
                            }
                            $user = OC_User::getUserSession()->getUser();
                    Severity: Minor
                    Found in lib/kernel.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;
                    Severity: Major
                    Found in lib/kernel.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return true;
                      Severity: Major
                      Found in lib/kernel.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return false;
                        Severity: Major
                        Found in lib/kernel.php - About 30 mins to fix

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

                              public static function checkInstalled() {
                                  if (\defined('OC_CONSOLE')) {
                                      return;
                                  }
                                  // Redirect to installer if not installed
                          Severity: Minor
                          Found in lib/kernel.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 handleAuthHeaders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected static function handleAuthHeaders() {
                                  //copy http auth headers for apache+php-fcgid work around
                                  if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
                                      $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION'];
                                  }
                          Severity: Minor
                          Found in lib/kernel.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 loadAppClassPaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function loadAppClassPaths() {
                                  foreach (OC_App::getEnabledApps() as $app) {
                                      $appPath = OC_App::getAppPath($app);
                                      if ($appPath === false) {
                                          continue;
                          Severity: Minor
                          Found in lib/kernel.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