phug-php/phug

View on GitHub

Showing 197 of 197 total issues

File AbstractFormat.php has 805 lines of code (exceeds 250 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

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

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      <?php
      
      namespace Phug\Parser\TokenHandler;
      
      use Phug\Lexer\Token\ClassToken;
      Severity: Major
      Found in src/Phug/Parser/Parser/TokenHandler/ClassTokenHandler.php and 1 other location - About 7 hrs to fix
      src/Phug/Parser/Parser/TokenHandler/IdTokenHandler.php on lines 1..45

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 184.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      <?php
      
      namespace Phug\Parser\TokenHandler;
      
      use Phug\Lexer\Token\IdToken;
      Severity: Major
      Found in src/Phug/Parser/Parser/TokenHandler/IdTokenHandler.php and 1 other location - About 7 hrs to fix
      src/Phug/Parser/Parser/TokenHandler/ClassTokenHandler.php on lines 1..46

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 184.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

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

        Function compileNode has a Cognitive Complexity of 41 (exceeds 5 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 6 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

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

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          <?php
          
          namespace Phug\Parser\Event;
          
          use Phug\Event;
          Severity: Major
          Found in src/Phug/Parser/Parser/Event/ParseEvent.php and 1 other location - About 5 hrs to fix
          src/Phug/Lexer/Lexer/Event/LexEvent.php on lines 1..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 151.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          <?php
          
          namespace Phug\Lexer\Event;
          
          use Phug\Event;
          Severity: Major
          Found in src/Phug/Lexer/Lexer/Event/LexEvent.php and 1 other location - About 5 hrs to fix
          src/Phug/Parser/Parser/Event/ParseEvent.php on lines 1..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 151.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

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

            AbstractFormat has 40 functions (exceeds 20 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 5 hrs to fix

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

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

                Node has 39 functions (exceeds 20 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 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

                    File Formatter.php has 342 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    namespace Phug;
                    
                    // Elements
                    Severity: Minor
                    Found in src/Phug/Formatter/Formatter.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

                        Function getSourceLine has a Cognitive Complexity of 27 (exceeds 5 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

                        File XmlFormat.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

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

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

                          Phug has 29 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Phug
                          {
                              use ExtensionsTrait;
                              use FacadeOptionsTrait;
                          
                          
                          Severity: Minor
                          Found in src/Phug/Phug/Phug/Phug.php - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language