phug-php/phug

View on GitHub

Showing 115 of 115 total issues

File Reader.php has 430 lines of code (exceeds 400 allowed). Consider refactoring.
Open

<?php

namespace Phug;

use Phug\Util\Partial\PathTrait;
Severity: Minor
Found in src/Phug/Reader/Reader.php - About 2 hrs to fix

    Function scanDirectory has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
    Open

        public function scanDirectory($directory, $extensions = null, $directoryCallback = null, $fileCallback = null)
        {
            if ($extensions === null) {
                $extensions = $this->getOption('extensions');
            }
    Severity: Minor
    Found in src/Phug/Renderer/Renderer/Partial/FileSystemTrait.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 __construct has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct(Formatter $formatter = null)
        {
            $this->setOptionsRecursive([
                'white_space_sensitive_tags' => [
                    'pre',
    Severity: Major
    Found in src/Phug/Formatter/Formatter/Format/XhtmlFormat.php - About 2 hrs to fix

      Function removeOptions has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
      Open

          public static function removeOptions($path, $options)
          {
              if (self::$renderer && (empty($path) || self::$renderer->hasOption($path))) {
                  if (is_array($options)) {
                      foreach ($options as $key => $value) {
      Severity: Minor
      Found in src/Phug/Phug/Phug/Phug.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

      Function handleTokens has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
      Open

          protected function handleTokens($code, $checked)
          {
              $phpTokenHandler = $this->getOption('php_token_handlers');
              $untouched = false;
      
      
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/AbstractFormat.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 isInExclusionContext has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function isInExclusionContext(&$tokens, $index)
          {
              foreach ([
                  // Exclude tokens before the variables
                  -1 => [
      Severity: Major
      Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.php - About 2 hrs to fix

        Method parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parse($input, $path = null)
            {
                $stateClassName = $this->getOption('parser_state_class_name');
        
                $event = new ParseEvent($input, $path, $stateClassName, [
        Severity: Major
        Found in src/Phug/Parser/Parser.php - About 2 hrs to fix

          Function getExposedProperties has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
          Open

              private function getExposedProperties($object, $deep)
              {
                  $result = "\n";
                  foreach (get_class_methods($object) as $method) {
                      if (mb_strlen($result) > 0x80000) {
          Severity: Minor
          Found in src/Phug/Renderer/Renderer/Profiler/Dump.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

          Function formatAttributeElement has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
          Open

              protected function formatAttributeElement(AttributeElement $element)
              {
                  $value = $element->getValue();
                  $name = $element->getName();
                  $nonEmptyAttribute = ($name === 'class' || $name === 'id');
          Severity: Minor
          Found in src/Phug/Formatter/Formatter/Format/XmlFormat.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 __construct has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($options = null)
              {
                  $this->initFormats()->setOptionsDefaults($options ?: [], [
                      'debug'                        => false,
                      'located_exception_class_name' => LocatedException::class,
          Severity: Major
          Found in src/Phug/Formatter/Formatter.php - About 2 hrs to fix

            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

              Method compose has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function compose($timePrecision, $lineHeight)
                  {
                      $duration = microtime(true) - $this->startTime;
                      $linkedProcesses = new LinkedProcesses($this->events, $this->nodesRegister);
              
              
              Severity: Minor
              Found in src/Phug/Renderer/Renderer/Profiler/Profile.php - About 1 hr to fix

                Method formatAttributeElement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function formatAttributeElement(AttributeElement $element)
                    {
                        $value = $element->getValue();
                        $name = $element->getName();
                        $nonEmptyAttribute = ($name === 'class' || $name === 'id');
                Severity: Minor
                Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 1 hr to fix

                  Method readExpression has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function readExpression(array $breaks = null, array $brackets = null)
                      {
                          if (!$this->hasLength()) {
                              return;
                          }
                  Severity: Minor
                  Found in src/Phug/Reader/Reader.php - About 1 hr to fix

                    Function scan has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
                    Open

                        public function scan(State $state)
                        {
                            $reader = $state->getReader();
                    
                            if ($reader->match('(?<raw>\!)?#\{')) {
                    Severity: Minor
                    Found in src/Phug/Lexer/Lexer/Scanner/DynamicTagScanner.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 displayFile has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function displayFile($__pug_file, array $__pug_parameters = [])
                        {
                            if ($this->isExpired($__pug_file, $__pug_cache_file)) {
                                if (isset($this->options['render'])) {
                                    call_user_func($this->options['render'], $__pug_file, $__pug_parameters, $this->options);
                    Severity: Minor
                    Found in src/Phug/Phug/Phug/Optimizer.php - About 1 hr 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 initProperties has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function initProperties($name, $events)
                          {
                              $style = [];
                              foreach ([
                                  ['current', EndLexEvent::class, 'lexing', [
                      Severity: Minor
                      Found in src/Phug/Renderer/Renderer/Profiler/LinkDump.php - About 1 hr to fix

                        Method getSourceLine has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getSourceLine($error)
                            {
                                $previous = null;
                                $line = null;
                        
                        
                        Severity: Minor
                        Found in src/Phug/Formatter/Formatter.php - About 1 hr to fix

                          Method handleTokens has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function handleTokens($code, $checked)
                              {
                                  $phpTokenHandler = $this->getOption('php_token_handlers');
                                  $untouched = false;
                          
                          
                          Severity: Minor
                          Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language