phug-php/phug

View on GitHub

Showing 113 of 115 total issues

File AbstractFormat.php has 806 lines of code (exceeds 400 allowed). Consider refactoring.
Open

<?php

namespace Phug\Formatter;

use Phug\Formatter;
Severity: Major
Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 day to fix

    Function compileNode has a Cognitive Complexity of 41 (exceeds 7 allowed). Consider refactoring.
    Open

        public function compileNode(NodeInterface $node, ElementInterface $parent = null)
        {
            $compiler = $this->getCompiler();
            $compiler->assert(
                $node instanceof ImportNode,
    Severity: Minor
    Found in src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.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

    File Compiler.php has 531 lines of code (exceeds 400 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Phug;
    
    // Node compilers
    Severity: Major
    Found in src/Phug/Compiler/Compiler.php - About 5 hrs to fix

      Method formatMixinCallElement has 117 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function formatMixinCallElement(MixinCallElement $mixinCall)
          {
              $hasBlock = $mixinCall->hasChildren();
              $children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
              $mixinName = $mixinCall->getName();
      Severity: Major
      Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 4 hrs to fix

        Method compileNode has 103 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function compileNode(NodeInterface $node, ElementInterface $parent = null)
            {
                $compiler = $this->getCompiler();
                $compiler->assert(
                    $node instanceof ImportNode,
        Severity: Major
        Found in src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.php - About 4 hrs to fix

          Reader has 42 functions (exceeds 30 allowed). Consider refactoring.
          Open

          class Reader
          {
              use PathTrait;
          
              /**
          Severity: Minor
          Found in src/Phug/Reader/Reader.php - About 4 hrs to fix

            Compiler has 41 functions (exceeds 30 allowed). Consider refactoring.
            Open

            class Compiler implements ModuleContainerInterface, CompilerInterface, WithUpperLocatorInterface
            {
                use ModuleContainerTrait;
                use YieldHandlerTrait;
            
            
            Severity: Minor
            Found in src/Phug/Compiler/Compiler.php - About 3 hrs to fix

              AbstractFormat has 40 functions (exceeds 30 allowed). Consider refactoring.
              Open

              abstract class AbstractFormat implements FormatInterface, OptionInterface
              {
                  use HandleVariable;
                  use OptionTrait;
                  use PatternTrait;
              Severity: Minor
              Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 3 hrs to fix

                Function getSourceLine has a Cognitive Complexity of 27 (exceeds 7 allowed). Consider refactoring.
                Open

                    private function getSourceLine($error)
                    {
                        $previous = null;
                        $line = null;
                
                
                Severity: Minor
                Found in src/Phug/Formatter/Formatter.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

                Node has 39 functions (exceeds 30 allowed). Consider refactoring.
                Open

                class Node implements NodeInterface
                {
                    /**
                     * Stores the current parent node of this node.
                     *
                Severity: Minor
                Found in src/Phug/Ast/Ast/Node.php - About 3 hrs to fix

                  State has 39 functions (exceeds 30 allowed). Consider refactoring.
                  Open

                  class State implements OptionInterface, EventManagerInterface
                  {
                      use OptionTrait;
                      use EventManagerTrait;
                  
                  
                  Severity: Minor
                  Found in src/Phug/Parser/Parser/State.php - About 3 hrs to fix

                    Method __construct has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct($options = null)
                        {
                            $this->setOptionsDefaults($options ?: [], [
                                'paths'                      => [],
                                'debug'                      => false,
                    Severity: Major
                    Found in src/Phug/Compiler/Compiler.php - About 3 hrs to fix

                      Function readExpression has a Cognitive Complexity of 25 (exceeds 7 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 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

                      Method __construct has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct($options = null)
                          {
                              $this->setOptionsDefaults($options ?: [], [
                                  'lexer_class_name'        => Lexer::class,
                                  'parser_state_class_name' => State::class,
                      Severity: Major
                      Found in src/Phug/Parser/Parser.php - About 3 hrs to fix

                        Method formatMixinElement has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function formatMixinElement(MixinElement $mixin)
                            {
                                $mixinName = $mixin->getName();
                                $name = is_string($mixinName)
                                    ? var_export($mixinName, true)
                        Severity: Major
                        Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 3 hrs to fix

                          File XmlFormat.php has 448 lines of code (exceeds 400 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          namespace Phug\Formatter\Format;
                          
                          use Closure;
                          Severity: Minor
                          Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 3 hrs to fix

                            Method __construct has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function __construct(Formatter $formatter = null)
                                {
                                    $patterns = [
                                        'class_attribute'        => static::CLASS_ATTRIBUTE,
                                        'string_attribute'       => static::STRING_ATTRIBUTE,
                            Severity: Major
                            Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 2 hrs to fix

                              Method yieldAssignmentElement has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function yieldAssignmentElement(AssignmentElement $element)
                                  {
                                      foreach ($this->getOption('assignment_handlers') as $handler) {
                                          $iterator = $handler($element) ?: [];
                              
                              
                              Severity: Major
                              Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 2 hrs to fix

                                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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language