pug-php/pug-symfony

View on GitHub

Showing 287 of 287 total issues

Function interpolateTwigFunctions has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    protected function interpolateTwigFunctions(string $code): string
    {
        $tokens = array_slice(token_get_all('<?php '.$code), 1);
        $output = '';
        $count = count($tokens);
Severity: Minor
Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 5 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

Function compileSource has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function compileSource(Source $source): string
    {
        $path = $source->getPath();

        if ($this->pugSymfonyEngine->supports($path)) {
Severity: Minor
Found in src/Pug/Twig/Environment.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

File HelpersHandler.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Pug\Symfony\Traits;

use Closure;
Severity: Minor
Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 2 hrs to fix

    Method interpolateTwigFunctions has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function interpolateTwigFunctions(string $code): string
        {
            $tokens = array_slice(token_get_all('<?php '.$code), 1);
            $output = '';
            $count = count($tokens);
    Severity: Major
    Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 2 hrs to fix

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

          protected function crawlDirectories(string $srcDir, array &$assetsDirectories, array &$viewDirectories): ?string
          {
              $baseDir = file_exists($viewDirectories[0]) ? $viewDirectories[0] : null;
      
              if (file_exists($srcDir)) {
      Severity: Minor
      Found in src/Pug/PugSymfonyEngine.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 compileSource has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function compileSource(Source $source): string
          {
              $path = $source->getPath();
      
              if ($this->pugSymfonyEngine->supports($path)) {
      Severity: Minor
      Found in src/Pug/Twig/Environment.php - About 1 hr to fix

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

            protected function getRendererOptions(): array
            {
                if ($this->options === null) {
                    $environment = $this->kernel->getEnvironment();
                    $projectDirectory = $this->kernel->getProjectDir();
        Severity: Minor
        Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 1 hr to fix

          Avoid excessively long variable names like $defaultTemplateDirectory. Keep variable name length under 20.
          Open

              protected $defaultTemplateDirectory;
          Severity: Minor
          Found in src/Pug/PugSymfonyEngine.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $argumentNeedInterpolation. Keep variable name length under 20.
          Open

                              $argumentNeedInterpolation = false;

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $argumentNeedInterpolation. Keep variable name length under 20.
          Open

              protected function pushArgument(array &$arguments, string &$argument, bool &$argumentNeedInterpolation)

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
          Open

                  $propertyAccessor->setValue($this->container, $services);

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$arguments' which will lead to PHP notices.
          Open

                  $arguments[] = $name;
          Severity: Minor
          Found in src/Pug/Twig/Environment.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
          Open

                  $services = static::getPrivateProperty($this->container, 'services', $propertyAccessor);

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
          Open

                      $propertyAccessor->setValue($container, $services);

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
          Open

                      $services = static::getPrivateProperty($container, 'services', $propertyAccessor);

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Method copyTwigFunctions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function copyTwigFunctions(): void
              {
                  $this->twigHelpers = [];
                  $twig = $this->getTwig();
                  $twig->env = $twig;
          Severity: Minor
          Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 1 hr to fix

            Method fromTwigEnvironment has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function fromTwigEnvironment(TwigEnvironment $baseTwig, PugSymfonyEngine $pugSymfonyEngine, ContainerInterface $container)
                {
                    $twig = new static($baseTwig->getLoader(), [
                        'debug'            => $baseTwig->isDebug(),
                        'charset'          => $baseTwig->getCharset(),
            Severity: Minor
            Found in src/Pug/Twig/Environment.php - About 1 hr to fix

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

                  protected function getRendererOptions(): array
                  {
                      if ($this->options === null) {
                          $environment = $this->kernel->getEnvironment();
                          $projectDirectory = $this->kernel->getProjectDir();
              Severity: Minor
              Found in src/Pug/Symfony/Traits/HelpersHandler.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

              Avoid variables with short names like $io. Configured minimum length is 3.
              Open

                  protected static function askConfirmation(IOInterface $io, $message)
              Severity: Minor
              Found in src/Pug/Symfony/Traits/Installer.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              Avoid variables with short names like $io. Configured minimum length is 3.
              Open

                  protected static function installSymfonyBundle(IOInterface $io, $dir, $bundle, $bundleClass, $proceedTask, &$flags)
              Severity: Minor
              Found in src/Pug/Symfony/Traits/Installer.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              Severity
              Category
              Status
              Source
              Language