phug-php/renderer

View on GitHub
Renderer/Partial/Debug/DebuggerTrait.php

Summary

Maintainability
D
1 day
Test Coverage

File DebuggerTrait.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Phug\Renderer\Partial\Debug;

use Phug\Formatter;
Severity: Minor
Found in Renderer/Partial/Debug/DebuggerTrait.php - About 3 hrs to fix

    Function getErrorMessage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getErrorMessage($error, SourceLocation $location, $data)
        {
            /* @var \Throwable $error */
            $source = explode("\n", rtrim($data->source));
            $errorType = get_class($error);
    Severity: Minor
    Found in Renderer/Partial/Debug/DebuggerTrait.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 getErrorMessage has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getErrorMessage($error, SourceLocation $location, $data)
        {
            /* @var \Throwable $error */
            $source = explode("\n", rtrim($data->source));
            $errorType = get_class($error);
    Severity: Minor
    Found in Renderer/Partial/Debug/DebuggerTrait.php - About 2 hrs to fix

      Method initDebugOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function initDebugOptions(Renderer $profilerContainer)
          {
              $profilerContainer->setOptionsDefaults([
                  'memory_limit'       => $profilerContainer->getOption('debug') ? 0x3200000 : -1, // 50MB by default in debug
                  'execution_max_time' => $profilerContainer->getOption('debug') ? 30000 : -1, // 30s by default in debug
      Severity: Minor
      Found in Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

        Function handleError has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handleError($error, $code, $path, $source, $parameters, $options)
            {
                /* @var \Throwable $error */
                $exception = $options['debug']
                    ? $this->getDebuggedException($error, $code, $source, $path, $parameters, $options)
        Severity: Minor
        Found in Renderer/Partial/Debug/DebuggerTrait.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 getRendererException has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getRendererException($error, $code, $line, $offset, $source, $sourcePath, $parameters, $options)
            {
                $colorSupport = $options['color_support'];
                if (is_null($colorSupport)) {
                    $colorSupport = $this->hasColorSupport();
        Severity: Minor
        Found in Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

          Method getErrorAsHtml has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getErrorAsHtml($error, $parameters, $data)
              {
                  $sandBox = new SandBox(function () use (
                      $error,
                      $parameters,
          Severity: Minor
          Found in Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

            Method getRendererException has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private function getRendererException($error, $code, $line, $offset, $source, $sourcePath, $parameters, $options)
            Severity: Major
            Found in Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

              Method getDebuggedException has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function getDebuggedException($error, $code, $source, $path, $parameters, $options)
              Severity: Minor
              Found in Renderer/Partial/Debug/DebuggerTrait.php - About 45 mins to fix

                Method handleError has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function handleError($error, $code, $path, $source, $parameters, $options)
                Severity: Minor
                Found in Renderer/Partial/Debug/DebuggerTrait.php - About 45 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status