phpmyadmin/phpmyadmin

View on GitHub
src/Error/ErrorHandler.php

Summary

Maintainability
D
2 days
Test Coverage

File ErrorHandler.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

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

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

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

      Method reportErrors has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function reportErrors(): void
          {
              // if there're no actual errors,
              if (! $this->hasErrors() || $this->countErrors() === $this->countUserErrors()) {
                  // then simply return.
      Severity: Minor
      Found in src/Error/ErrorHandler.php - About 1 hr to fix

        Function getDispErrors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getDispErrors(): string
            {
                $retval = '';
                // display errors if SendErrorReports is set to 'ask'.
                $config = Config::getInstance();
        Severity: Minor
        Found in src/Error/ErrorHandler.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 getDispErrors has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getDispErrors(): string
            {
                $retval = '';
                // display errors if SendErrorReports is set to 'ask'.
                $config = Config::getInstance();
        Severity: Minor
        Found in src/Error/ErrorHandler.php - About 1 hr to fix

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

              public function addError(
                  string $errstr,
                  int $errno,
                  string $errfile,
                  int $errline,
          Severity: Minor
          Found in src/Error/ErrorHandler.php - About 1 hr to fix

            Function reportErrors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function reportErrors(): void
                {
                    // if there're no actual errors,
                    if (! $this->hasErrors() || $this->countErrors() === $this->countUserErrors()) {
                        // then simply return.
            Severity: Minor
            Found in src/Error/ErrorHandler.php - About 55 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 handleError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function handleError(
                    int $errno,
                    string $errstr,
                    string $errfile,
                    int $errline,
            Severity: Minor
            Found in src/Error/ErrorHandler.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 __destruct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __destruct()
                {
                    if (! isset($_SESSION['errors'])) {
                        $_SESSION['errors'] = [];
                    }
            Severity: Minor
            Found in src/Error/ErrorHandler.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 addError has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $errstr,
                    int $errno,
                    string $errfile,
                    int $errline,
                    bool $escape = true,
            Severity: Minor
            Found in src/Error/ErrorHandler.php - About 35 mins to fix

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

                  public function countUserErrors(): int
                  {
                      $count = 0;
                      if ($this->countErrors() !== 0) {
                          foreach ($this->getErrors() as $error) {
              Severity: Minor
              Found in src/Error/ErrorHandler.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 checkSavedErrors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function checkSavedErrors(): void
                  {
                      if (! isset($_SESSION['errors'])) {
                          return;
                      }
              Severity: Minor
              Found in src/Error/ErrorHandler.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