owncloud/core

View on GitHub
lib/private/Installer.php

Summary

Maintainability
F
3 days
Test Coverage

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

    protected static function getShippedApps() {
        $shippedApps = [];
        foreach (\OC::$APPSROOTS as $app_dir) {
            if ($dir = \opendir($app_dir['path'])) {
                $nodes = \scandir($app_dir['path']);
Severity: Minor
Found in lib/private/Installer.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 checkAppsIntegrity has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped = false) {
        $l = \OC::$server->getL10N('lib');
        //load the info.xml file of the app
        if (!\is_file($extractDir.'/appinfo/info.xml')) {
            //try to find it in a subdir
Severity: Minor
Found in lib/private/Installer.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

File Installer.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Brice Maron <brice@bmaron.net>
Severity: Minor
Found in lib/private/Installer.php - About 3 hrs to fix

    Function installApp has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function installApp($data = []) {
            $l = \OC::$server->getL10N('lib');
    
            list($extractDir, $path) = self::downloadApp($data);
    
    
    Severity: Minor
    Found in lib/private/Installer.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 installApp has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function installApp($data = []) {
            $l = \OC::$server->getL10N('lib');
    
            list($extractDir, $path) = self::downloadApp($data);
    
    
    Severity: Major
    Found in lib/private/Installer.php - About 2 hrs to fix

      Method checkAppsIntegrity has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped = false) {
              $l = \OC::$server->getL10N('lib');
              //load the info.xml file of the app
              if (!\is_file($extractDir.'/appinfo/info.xml')) {
                  //try to find it in a subdir
      Severity: Major
      Found in lib/private/Installer.php - About 2 hrs to fix

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

            public static function downloadApp($data = []) {
                $l = \OC::$server->getL10N('lib');
        
                if (!isset($data['source'])) {
                    throw new \Exception($l->t("No source specified when installing app"));
        Severity: Minor
        Found in lib/private/Installer.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 downloadApp has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function downloadApp($data = []) {
                $l = \OC::$server->getL10N('lib');
        
                if (!isset($data['source'])) {
                    throw new \Exception($l->t("No source specified when installing app"));
        Severity: Minor
        Found in lib/private/Installer.php - About 1 hr to fix

          Function installShippedApps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function installShippedApps($softErrors = false) {
                  $errors = [];
                  $appsToInstall = Installer::getShippedApps();
          
                  foreach ($appsToInstall as $appToInstall) {
          Severity: Minor
          Found in lib/private/Installer.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 installShippedApp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function installShippedApp($app) {
                  \OC::$server->getLogger()->info('Attempting to install shipped app: '.$app);
          
                  $info = OC_App::getAppInfo($app);
                  if ($info === null) {
          Severity: Minor
          Found in lib/private/Installer.php - About 1 hr to fix

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

                protected static function getShippedApps() {
                    $shippedApps = [];
                    foreach (\OC::$APPSROOTS as $app_dir) {
                        if ($dir = \opendir($app_dir['path'])) {
                            $nodes = \scandir($app_dir['path']);
            Severity: Minor
            Found in lib/private/Installer.php - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (\is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) {
                                          $extractDir.='/'.$folder;
                                      }
              Severity: Major
              Found in lib/private/Installer.php - About 45 mins to fix

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

                    public static function installShippedApp($app) {
                        \OC::$server->getLogger()->info('Attempting to install shipped app: '.$app);
                
                        $info = OC_App::getAppInfo($app);
                        if ($info === null) {
                Severity: Minor
                Found in lib/private/Installer.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

                Avoid deeply nested control flow statements.
                Open

                                                if (($enabled || \in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
                                                    && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
                                                    $shippedApps[] = $filename;
                                                }
                Severity: Major
                Found in lib/private/Installer.php - About 45 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status