owncloud/core

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

Summary

Maintainability
F
6 days
Test Coverage

File app.php has 664 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
Severity: Major
Found in lib/private/legacy/app.php - About 1 day to fix

    Function listAllApps has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function listAllApps(bool $listEveryApp = false) {
            $installedApps = OC_App::getAllApps();
    
            //TODO which apps do we want to blacklist and how do we integrate
            // blacklisting with the multi apps folder feature?
    Severity: Minor
    Found in lib/private/legacy/app.php - About 1 day 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

    OC_App has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OC_App {
        private static $adminForms = [];
        private static $personalForms = [];
        private static $appTypes = [];
        private static $loadedApps = [];
    Severity: Minor
    Found in lib/private/legacy/app.php - About 6 hrs to fix

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

          public static function loadApps($types = null) {
              if (\is_array($types) && !\array_diff($types, self::$loadedTypes)) {
                  return true;
              }
              if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
      Severity: Minor
      Found in lib/private/legacy/app.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

      Method listAllApps has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function listAllApps(bool $listEveryApp = false) {
              $installedApps = OC_App::getAllApps();
      
              //TODO which apps do we want to blacklist and how do we integrate
              // blacklisting with the multi apps folder feature?
      Severity: Major
      Found in lib/private/legacy/app.php - About 2 hrs to fix

        Function loadApp has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function loadApp($app, $checkUpgrade = true) {
                self::$loadedApps[] = $app;
                $appPath = self::getAppPath($app);
                if ($appPath === false) {
                    return;
        Severity: Minor
        Found in lib/private/legacy/app.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 loadApps has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function loadApps($types = null) {
                if (\is_array($types) && !\array_diff($types, self::$loadedTypes)) {
                    return true;
                }
                if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
        Severity: Major
        Found in lib/private/legacy/app.php - About 2 hrs to fix

          Function getAllApps has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getAllApps() {
                  $apps = [];
          
                  foreach (OC::$APPSROOTS as $apps_dir) {
                      if (!\is_readable($apps_dir['path'])) {
          Severity: Minor
          Found in lib/private/legacy/app.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 loadApp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function loadApp($app, $checkUpgrade = true) {
                  self::$loadedApps[] = $app;
                  $appPath = self::getAppPath($app);
                  if ($appPath === false) {
                      return;
          Severity: Minor
          Found in lib/private/legacy/app.php - About 1 hr to fix

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

                public static function isAppDirWritable($appId) {
                    $path = self::getAppPath($appId);
                    // Check if the parent directory is marked as writable in config.php
                    if ($path !== false) {
                        $appDir = \substr($path, 0, -\strlen("/$appId"));
            Severity: Minor
            Found in lib/private/legacy/app.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 updateApp has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function updateApp($appId) {
                    \OC::$server->getAppManager()->clearAppsCache();
                    $appPath = self::getAppPath($appId);
                    if ($appPath === false) {
                        return false;
            Severity: Minor
            Found in lib/private/legacy/app.php - About 1 hr to fix

              Method isAppCompatible has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function isAppCompatible($ocVersion, $appInfo) {
                      $requireMin = '';
                      $requireMax = '';
                      if (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
                          $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
              Severity: Minor
              Found in lib/private/legacy/app.php - About 1 hr to fix

                Method getSettingsNavigation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getSettingsNavigation() {
                        $l = \OC::$server->getL10N('lib');
                        $urlGenerator = \OC::$server->getURLGenerator();
                
                        $settings = [];
                Severity: Minor
                Found in lib/private/legacy/app.php - About 1 hr to fix

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

                      public static function isAppCompatible($ocVersion, $appInfo) {
                          $requireMin = '';
                          $requireMax = '';
                          if (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
                              $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
                  Severity: Minor
                  Found in lib/private/legacy/app.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 updateApp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function updateApp($appId) {
                          \OC::$server->getAppManager()->clearAppsCache();
                          $appPath = self::getAppPath($appId);
                          if ($appPath === false) {
                              return false;
                  Severity: Minor
                  Found in lib/private/legacy/app.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 enable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function enable($app, $groups = null) {
                          self::$enabledAppsCache = []; // flush
                  
                          // check for required dependencies
                          $config = \OC::$server->getConfig();
                  Severity: Minor
                  Found in lib/private/legacy/app.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 getStorage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function getStorage($appId) {
                          if (OC_App::isEnabled($appId)) { //sanity check
                              if (OC_User::isLoggedIn()) {
                                  $view = new \OC\Files\View('/' . OC_User::getUser());
                                  if (!$view->file_exists($appId)) {
                  Severity: Minor
                  Found in lib/private/legacy/app.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 parseAppInfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function parseAppInfo(array $data) {
                          // just modify the description if it is available
                          // otherwise this will create a $data element with an empty 'description'
                          if (isset($data['description'])) {
                              if (\is_string($data['description'])) {
                  Severity: Minor
                  Found in lib/private/legacy/app.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 shouldUpgrade has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function shouldUpgrade($app) {
                          $versions = self::getAppVersions();
                          $info = \OC::$server->getAppManager()->getAppInfo($app);
                  
                          if ($info && isset($versions[$app])) {
                  Severity: Minor
                  Found in lib/private/legacy/app.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