phpmyadmin/phpmyadmin

View on GitHub
src/Core.php

Summary

Maintainability
D
3 days
Test Coverage

File Core.php has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace PhpMyAdmin;
Severity: Minor
Found in src/Core.php - About 7 hrs to fix

    Function safeUnserialize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function safeUnserialize(string $data): mixed
        {
            /* validate serialized data */
            $length = strlen($data);
            $depth = 0;
    Severity: Minor
    Found in src/Core.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

    Core has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Core
    {
        /**
         * Removes insecure parts in a path; used before include() or
         * require() when a part of the path comes from an insecure source
    Severity: Minor
    Found in src/Core.php - About 2 hrs to fix

      Method safeUnserialize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function safeUnserialize(string $data): mixed
          {
              /* validate serialized data */
              $length = strlen($data);
              $depth = 0;
      Severity: Major
      Found in src/Core.php - About 2 hrs to fix

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

            public static function populateRequestWithEncryptedQueryParams(ServerRequest $request): ServerRequest
            {
                $queryParams = $request->getQueryParams();
                $parsedBody = $request->getParsedBody();
        
        
        Severity: Minor
        Found in src/Core.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 populateRequestWithEncryptedQueryParams has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function populateRequestWithEncryptedQueryParams(ServerRequest $request): ServerRequest
            {
                $queryParams = $request->getQueryParams();
                $parsedBody = $request->getParsedBody();
        
        
        Severity: Minor
        Found in src/Core.php - About 1 hr to fix

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

              public static function isAllowedDomain(string $url): bool
              {
                  $parsedUrl = parse_url($url);
                  if (
                      ! is_array($parsedUrl)
          Severity: Minor
          Found in src/Core.php - About 1 hr to fix

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

                public static function arrayRemove(string $path, array &$array): void
                {
                    $keys = explode('/', $path);
                    $keysLast = array_pop($keys);
                    $path = [];
            Severity: Minor
            Found in src/Core.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

            Consider simplifying this complex logical expression.
            Open

                    if (
                        is_array($parsedBody)
                        && isset($parsedBody['eq'])
                        && is_string($parsedBody['eq'])
                        && $parsedBody['eq'] !== ''
            Severity: Major
            Found in src/Core.php - About 40 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return null;
              Severity: Major
              Found in src/Core.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                        return null;
                Severity: Major
                Found in src/Core.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $request;
                  Severity: Major
                  Found in src/Core.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return null;
                    Severity: Major
                    Found in src/Core.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return null;
                      Severity: Major
                      Found in src/Core.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return unserialize($data);
                        Severity: Major
                        Found in src/Core.php - About 30 mins to fix

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

                              public static function previewSQL(array|string $queryData): void
                              {
                                  $retval = '<div class="preview_sql">';
                                  if ($queryData === '' || $queryData === []) {
                                      $retval .= __('No change');
                          Severity: Minor
                          Found in src/Core.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