phug-php/phug

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

Summary

Maintainability
C
1 day
Test Coverage
A
100%

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 src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 2 hrs to fix

    Function getErrorMessage has a Cognitive Complexity of 16 (exceeds 7 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 src/Phug/Renderer/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 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 src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

      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 src/Phug/Renderer/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 src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

          Function handleError has a Cognitive Complexity of 11 (exceeds 7 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 src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.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

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

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

            There are no issues that match your filters.

            Category
            Status