phpmyadmin/phpmyadmin

View on GitHub
src/Config.php

Summary

Maintainability
F
6 days
Test Coverage

File Config.php has 771 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace PhpMyAdmin;
Severity: Major
Found in src/Config.php - About 1 day to fix

    Config has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Config
    {
        public static self|null $instance = null;
    
        /** @var mixed[]   default configuration settings */
    Severity: Minor
    Found in src/Config.php - About 5 hrs to fix

      Function loadUserPreferences has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumCommon = false): void
          {
              $cacheKey = 'server_' . Current::$server;
              if (Current::$server > 0 && ! $isMinimumCommon) {
                  // cache user preferences, use database only when needed
      Severity: Minor
      Found in src/Config.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 loadUserPreferences has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumCommon = false): void
          {
              $cacheKey = 'server_' . Current::$server;
              if (Current::$server > 0 && ! $isMinimumCommon) {
                  // cache user preferences, use database only when needed
      Severity: Major
      Found in src/Config.php - About 2 hrs to fix

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

            public function selectServer(mixed $serverParamFromRequest): int
            {
                $serverNumber = 0;
                if (is_numeric($serverParamFromRequest)) {
                    $serverNumber = (int) $serverParamFromRequest;
        Severity: Minor
        Found in src/Config.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 getConnectionParams has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
            {
                if ($connectionType !== ConnectionType::ControlUser) {
                    if ($currentServer->host !== '' && $currentServer->port !== '') {
                        return $currentServer;
        Severity: Major
        Found in src/Config.php - About 2 hrs to fix

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

              public function checkClient(): void
              {
                  $httpUserAgent = '';
                  if (Core::getEnv('HTTP_USER_AGENT') !== '') {
                      $httpUserAgent = Core::getEnv('HTTP_USER_AGENT');
          Severity: Minor
          Found in src/Config.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 checkClient has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function checkClient(): void
              {
                  $httpUserAgent = '';
                  if (Core::getEnv('HTTP_USER_AGENT') !== '') {
                      $httpUserAgent = Core::getEnv('HTTP_USER_AGENT');
          Severity: Minor
          Found in src/Config.php - About 1 hr to fix

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

                public function setCookie(
                    string $cookie,
                    string $value,
                    string|null $default = null,
                    int|null $validity = null,
            Severity: Minor
            Found in src/Config.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 isHttps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function isHttps(): bool
                {
                    /** @var mixed $isHttps */
                    $isHttps = $this->get('is_https');
                    if (is_bool($isHttps)) {
            Severity: Minor
            Found in src/Config.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 selectServer has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function selectServer(mixed $serverParamFromRequest): int
                {
                    $serverNumber = 0;
                    if (is_numeric($serverParamFromRequest)) {
                        $serverNumber = (int) $serverParamFromRequest;
            Severity: Minor
            Found in src/Config.php - About 1 hr to fix

              Method setCookie has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function setCookie(
                      string $cookie,
                      string $value,
                      string|null $default = null,
                      int|null $validity = null,
              Severity: Minor
              Found in src/Config.php - About 1 hr to fix

                Method load has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function load(string|null $source = null): bool
                    {
                        if ($source !== null) {
                            $this->setSource($source);
                        }
                Severity: Minor
                Found in src/Config.php - About 1 hr to fix

                  Method isHttps has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function isHttps(): bool
                      {
                          /** @var mixed $isHttps */
                          $isHttps = $this->get('is_https');
                          if (is_bool($isHttps)) {
                  Severity: Minor
                  Found in src/Config.php - About 1 hr to fix

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

                        public function getRootPath(): string
                        {
                            $url = $this->get('PmaAbsoluteUri');
                    
                            if (! empty($url)) {
                    Severity: Minor
                    Found in src/Config.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 getTempDir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getTempDir(string $name): string|null
                        {
                            if (isset(self::$tempDir[$name])) {
                                return self::$tempDir[$name];
                            }
                    Severity: Minor
                    Found in src/Config.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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function load(string|null $source = null): bool
                        {
                            if ($source !== null) {
                                $this->setSource($source);
                            }
                    Severity: Minor
                    Found in src/Config.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

                    Method setCookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            string $cookie,
                            string $value,
                            string|null $default = null,
                            int|null $validity = null,
                            bool $httponly = true,
                    Severity: Minor
                    Found in src/Config.php - About 35 mins to fix

                      Function checkConfigSource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function checkConfigSource(): bool
                          {
                              if ($this->getSource() === '') {
                                  // no configuration file set at all
                                  return false;
                      Severity: Minor
                      Found in src/Config.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 getConnectionParams has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
                          {
                              if ($connectionType !== ConnectionType::ControlUser) {
                                  if ($currentServer->host !== '' && $currentServer->port !== '') {
                                      return $currentServer;
                      Severity: Minor
                      Found in src/Config.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 setUserValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function setUserValue(
                              string|null $cookieName,
                              string $cfgPath,
                              mixed $newCfgValue,
                              string|null $defaultValue = null,
                      Severity: Minor
                      Found in src/Config.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 true;
                      Severity: Major
                      Found in src/Config.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return setcookie($httpCookieName, $value, $optionalParams);
                        Severity: Major
                        Found in src/Config.php - About 30 mins to fix

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

                              private function setClientPlatform(string $userAgent): void
                              {
                                  if (str_contains($userAgent, 'Win')) {
                                      $this->set('PMA_USR_OS', 'Win');
                                  } elseif (str_contains($userAgent, 'Mac')) {
                          Severity: Minor
                          Found in src/Config.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 checkGd2 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function checkGd2(): void
                              {
                                  if ($this->get('GD2Available') === 'yes') {
                                      $this->set('PMA_IS_GD2', 1);
                          
                          
                          Severity: Minor
                          Found in src/Config.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