owncloud/core

View on GitHub
lib/private/App/AppManager.php

Summary

Maintainability
F
3 days
Test Coverage

File AppManager.php has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Christoph Schaefer <christophł@wolkesicher.de>
 * @author Christoph Wurst <christoph@owncloud.com>
Severity: Minor
Found in lib/private/App/AppManager.php - About 6 hrs to fix

    AppManager has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AppManager implements IAppManager {
        /**
         * Apps with these types can not be enabled for certain groups only
         * @var string[]
         */
    Severity: Minor
    Found in lib/private/App/AppManager.php - About 4 hrs to fix

      Function checkAppForUser has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          private function checkAppForUser($enabled, $appName, $user) {
              if ($user !== null) {
                  $userAppAttributes = $user->getExtendedAttributes();
                  /**
                   * Guests will only have access to some whitelisted apps
      Severity: Minor
      Found in lib/private/App/AppManager.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 findAppInDirectories has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function findAppInDirectories($appId) {
              $sanitizedAppId = \OC_App::cleanAppId($appId);
              if ($sanitizedAppId !== $appId) {
                  return false;
              }
      Severity: Minor
      Found in lib/private/App/AppManager.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 getAppInfoByPath has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getAppInfoByPath($path, $etag = null) {
              $file = \realpath($path);
      
              // check the cache
              $data = $this->appInfo->get($file);
      Severity: Minor
      Found in lib/private/App/AppManager.php - About 1 hr to fix

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

            protected function canEnableTheme($appId) {
                $info = $this->getAppInfo($appId);
                if (
                    isset($info['types'])
                    && \is_array($info['types'])
        Severity: Minor
        Found in lib/private/App/AppManager.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 checkAppForUser has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function checkAppForUser($enabled, $appName, $user) {
                if ($user !== null) {
                    $userAppAttributes = $user->getExtendedAttributes();
                    /**
                     * Guests will only have access to some whitelisted apps
        Severity: Minor
        Found in lib/private/App/AppManager.php - About 1 hr to fix

          Method findAppInDirectories has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function findAppInDirectories($appId) {
                  $sanitizedAppId = \OC_App::cleanAppId($appId);
                  if ($sanitizedAppId !== $appId) {
                      return false;
                  }
          Severity: Minor
          Found in lib/private/App/AppManager.php - About 1 hr to fix

            Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    IUserSession $userSession = null,
                    IAppConfig $appConfig = null,
                    IGroupManager $groupManager = null,
                    ICacheFactory $memCacheFactory,
                    EventDispatcherInterface $dispatcher,
            Severity: Minor
            Found in lib/private/App/AppManager.php - About 45 mins to fix

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

                  public function getAppInfoByPath($path, $etag = null) {
                      $file = \realpath($path);
              
                      // check the cache
                      $data = $this->appInfo->get($file);
              Severity: Minor
              Found in lib/private/App/AppManager.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 getAppInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getAppInfo($appId) {
                      if (!\is_string($appId) || $appId === '') {
                          return null; // TODO explode?
                      }
              
              
              Severity: Minor
              Found in lib/private/App/AppManager.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 too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                    There are no issues that match your filters.

                    Category
                    Status