owncloud/core

View on GitHub
lib/private/Settings/SettingsManager.php

Summary

Maintainability
C
1 day
Test Coverage

File SettingsManager.php has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Tom Needham <tom@owncloud.com>
 *
 * @copyright Copyright (c) 2018, ownCloud GmbH
Severity: Minor
Found in lib/private/Settings/SettingsManager.php - About 3 hrs to fix

    Function findRegisteredSections has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function findRegisteredSections($type) {
            $sections = [];
            foreach ($this->appManager->getEnabledAppsForUser($this->userSession->getUser()) as $app) {
                if (isset($this->appManager->getAppInfo($app)['settings-sections'])) {
                    foreach ($this->appManager->getAppInfo($app)['settings-sections'] as $t => $section) {
    Severity: Minor
    Found in lib/private/Settings/SettingsManager.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 getBuiltInPanel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getBuiltInPanel($className) {
            $panels = [
                // Personal
                Profile::class => new Profile(
                    $this->config,
    Severity: Minor
    Found in lib/private/Settings/SettingsManager.php - About 1 hr to fix

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

              IL10N $l,
              IAppManager $appManager,
              IUserSession $userSession,
              ILogger $logger,
              IGroupManager $groupManager,
      Severity: Major
      Found in lib/private/Settings/SettingsManager.php - About 1 hr to fix

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

            private function getBuiltInPanels($type) {
                if ($type === 'admin') {
                    return [
                        Enforce2fa::class,
                        LegacyAdmin::class,
        Severity: Minor
        Found in lib/private/Settings/SettingsManager.php - About 1 hr to fix

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

              protected function findRegisteredPanels($type) {
                  $panels = [];
                  foreach ($this->appManager->getEnabledAppsForUser($this->userSession->getUser()) as $app) {
                      if (isset($this->appManager->getAppInfo($app)['settings'])) {
                          foreach ($this->appManager->getAppInfo($app)['settings'] as $t => $detected) {
          Severity: Minor
          Found in lib/private/Settings/SettingsManager.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 loadPanels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function loadPanels($type) {
                  // If already loaded just return
                  if (!empty($this->panels[$type])) {
                      return $this->panels[$type];
                  }
          Severity: Minor
          Found in lib/private/Settings/SettingsManager.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 loadSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function loadSection($type, $sectionID) {
                  // Load built in sections
                  foreach ($this->getBuiltInSections($type) as $section) {
                      if ($section->getID() === $sectionID) {
                          return $section;
          Severity: Minor
          Found in lib/private/Settings/SettingsManager.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