phpmyadmin/phpmyadmin

View on GitHub
src/ResponseRenderer.php

Summary

Maintainability
D
2 days
Test Coverage

File ResponseRenderer.php has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

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

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

        private function ajaxResponse(): string
        {
            if (! isset($this->JSON['message'])) {
                $this->JSON['message'] = $this->HTML;
            } elseif ($this->JSON['message'] instanceof Message) {
    Severity: Minor
    Found in src/ResponseRenderer.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

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

    class ResponseRenderer
    {
        private static ResponseRenderer|null $instance = null;
    
        /**
    Severity: Minor
    Found in src/ResponseRenderer.php - About 2 hrs to fix

      Method ajaxResponse has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function ajaxResponse(): string
          {
              if (! isset($this->JSON['message'])) {
                  $this->JSON['message'] = $this->HTML;
              } elseif ($this->JSON['message'] instanceof Message) {
      Severity: Major
      Found in src/ResponseRenderer.php - About 2 hrs to fix

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

            public function checkParameters(array $params, bool $request = false): bool
            {
                $foundError = false;
                $errorMessage = '';
                $array = $request ? $_REQUEST : $GLOBALS;
        Severity: Minor
        Found in src/ResponseRenderer.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 checkParameters has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function checkParameters(array $params, bool $request = false): bool
            {
                $foundError = false;
                $errorMessage = '';
                $array = $request ? $_REQUEST : $GLOBALS;
        Severity: Minor
        Found in src/ResponseRenderer.php - About 1 hr to fix

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

                  protected Config $config,
                  protected Template $template,
                  protected Header $header,
                  protected Footer $footer,
                  protected ErrorHandler $errorHandler,
          Severity: Major
          Found in src/ResponseRenderer.php - About 50 mins to fix

            There are no issues that match your filters.

            Category
            Status