phug-php/phug

View on GitHub

Showing 113 of 115 total issues

Method getNodeName has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getNodeName(NodeInterface $node)
    {
        switch (get_class($node)) {
            case ElementNode::class:
                $text = get_class($node);
Severity: Minor
Found in src/Phug/Parser/Parser.php - About 1 hr to fix

    Method lex has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function lex($input, $path = null)
        {
            $stateClassName = $this->getOption('lexer_state_class_name');
            $lexEvent = new LexEvent($input, $path, $stateClassName, [
                'encoding'                 => $this->getOption('encoding'),
    Severity: Minor
    Found in src/Phug/Lexer/Lexer.php - About 1 hr to fix

      Method scan has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              $reader = $state->getReader();
      
              foreach ($state->scanToken(
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/FilterScanner.php - About 1 hr to fix

        Method provideAttributesAssignment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function provideAttributesAssignment()
            {
                return $this
                    ->registerHelper(
                        'attributes_mapping',
        Severity: Minor
        Found in src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php - About 1 hr to fix

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

          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 scan has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
          Open

              public function scan(State $state)
              {
                  $reader = $state->getReader();
          
                  foreach ($state->scanToken(
          Severity: Minor
          Found in src/Phug/Lexer/Lexer/Scanner/FilterScanner.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

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

              public function scan(State $state)
              {
                  $reader = $state->getReader();
          
                  //Text block on tags etc. (p. some text|p!. some text)
          Severity: Minor
          Found in src/Phug/Lexer/Lexer/Scanner/SubScanner.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 setFormatter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function setFormatter(Formatter $formatter)
              {
                  $this->formatter = $formatter;
                  $format = $this;
          
          
          Severity: Minor
          Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

            Method formatElementChildren has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
                {
                    $indentLevel = $this->formatter->getLevel();
                    $this->formatter->setLevel($indentLevel + $indentStep);
                    $content = '';
            Severity: Minor
            Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

              Method getList has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function getList()
                  {
                      return [
                          //TODO: Several of these are non-standard and need to be encapsulated into extensions
                          //Namely: ForScanner, DoScanner, VariableScanner
              Severity: Minor
              Found in src/Phug/Lexer/Scanners.php - About 1 hr to fix

                Method scan has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function scan(State $state)
                    {
                        $reader = $state->getReader();
                
                        if (!$reader->peekString('//')) {
                Severity: Minor
                Found in src/Phug/Lexer/Lexer/Scanner/CommentScanner.php - About 1 hr to fix

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

                      public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                      {
                          $compiler = $this->getCompiler();
                          $compiler->assert(
                              $node instanceof FilterNode,
                  Severity: Minor
                  Found in src/Phug/Compiler/Compiler/NodeCompiler/FilterNodeCompiler.php - About 1 hr to fix

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

                        public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                        {
                            $compiler = $this->getCompiler();
                            $compiler->assert(
                                $node instanceof ElementNode,
                    Severity: Minor
                    Found in src/Phug/Compiler/Compiler/NodeCompiler/ElementNodeCompiler.php - About 1 hr to fix

                      Method readString has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function readString(array $escapeSequences = null, $raw = false)
                          {
                              if (!$this->peekQuote()) {
                                  return;
                              }
                      Severity: Minor
                      Found in src/Phug/Reader/Reader.php - About 1 hr to fix

                        Function findChildren has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
                        Open

                            public function findChildren(callable $callback, $depth = null, $level = null)
                            {
                                $level = $level ?: 0;
                        
                                foreach ($this->children as $child) {
                        Severity: Minor
                        Found in src/Phug/Ast/Ast/Node.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

                        Function hasNonStaticAttributes has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
                        Open

                            protected function hasNonStaticAttributes(MarkupInterface $element)
                            {
                                if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
                                    foreach ($element->getAttributes() as $attribute) {
                                        if ($attribute->hasStaticMember('value')) {
                        Severity: Minor
                        Found in src/Phug/Formatter/Formatter/Format/XmlFormat.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

                        Function isInExclusionContext has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
                        Open

                            private function isInExclusionContext(&$tokens, $index)
                            {
                                foreach ([
                                    // Exclude tokens before the variables
                                    -1 => [
                        Severity: Minor
                        Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.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

                        Function getNodeName has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
                        Open

                            protected function getNodeName(NodeInterface $node)
                            {
                                switch (get_class($node)) {
                                    case ElementNode::class:
                                        $text = get_class($node);
                        Severity: Minor
                        Found in src/Phug/Parser/Parser.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 __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function __construct(Formatter $formatter = null)
                            {
                                parent::__construct($formatter);
                        
                                $this
                        Severity: Minor
                        Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 1 hr to fix

                          Method getDebugError has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getDebugError($error, $code, $path = null)
                              {
                                  /** @var \Throwable $error */
                                  $line = $this->getSourceLine($error);
                                  if ($line === false) {
                          Severity: Minor
                          Found in src/Phug/Formatter/Formatter.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language