phug-php/parser

View on GitHub

Showing 17 of 17 total issues

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

class State implements OptionInterface, EventManagerInterface
{
    use OptionTrait;
    use EventManagerTrait;

Severity: Minor
Found in Parser/State.php - About 5 hrs to fix

    File State.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Phug\Parser;
    
    use Phug\EventManagerInterface;
    Severity: Minor
    Found in Parser/State.php - About 3 hrs to fix

      File Parser.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Phug;
      
      use Phug\Lexer\Token\AssignmentToken;
      Severity: Minor
      Found in Parser.php - About 3 hrs to fix

        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 Parser.php - About 3 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 Parser.php - About 2 hrs to fix

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

                protected function getNodeName(NodeInterface $node)
                {
                    switch (get_class($node)) {
                        case ElementNode::class:
                            $text = get_class($node);
            Severity: Minor
            Found in 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 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 Parser.php - About 1 hr to fix

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

              <?php
              
              namespace Phug\Parser\TokenHandler;
              
              use Phug\Lexer\Token\ExpressionToken;
              Severity: Major
              Found in Parser/TokenHandler/ExpressionTokenHandler.php and 1 other location - About 1 hr to fix
              Parser/TokenHandler/EachTokenHandler.php on lines 1..22

              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 104.

              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\EachToken;
              Severity: Major
              Found in Parser/TokenHandler/EachTokenHandler.php and 1 other location - About 1 hr to fix
              Parser/TokenHandler/ExpressionTokenHandler.php on lines 1..23

              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 104.

              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

              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      TokenInterface $token = null,
                      SourceLocationInterface $sourceLocation = null,
                      $level = null,
                      NodeInterface $parent = null,
                      array $children = null
              Severity: Minor
              Found in Parser/Node.php - About 35 mins to fix

                Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        SourceLocation $location,
                        $message = '',
                        $code = 0,
                        TokenInterface $relatedToken = null,
                        $previous = null
                Severity: Minor
                Found in ParserException.php - About 35 mins to fix

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

                  <?php
                  
                  namespace Phug\Parser\TokenHandler;
                  
                  use Phug\Lexer\Token\KeywordToken;
                  Severity: Major
                  Found in Parser/TokenHandler/KeywordTokenHandler.php and 3 other locations - About 35 mins to fix
                  Parser/TokenHandler/BlockTokenHandler.php on lines 1..21
                  Parser/TokenHandler/ConditionalTokenHandler.php on lines 1..21
                  Parser/TokenHandler/WhenTokenHandler.php on lines 1..21

                  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 92.

                  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 4 locations. Consider refactoring.
                  Open

                  <?php
                  
                  namespace Phug\Parser\TokenHandler;
                  
                  use Phug\Lexer\Token\WhenToken;
                  Severity: Major
                  Found in Parser/TokenHandler/WhenTokenHandler.php and 3 other locations - About 35 mins to fix
                  Parser/TokenHandler/BlockTokenHandler.php on lines 1..21
                  Parser/TokenHandler/ConditionalTokenHandler.php on lines 1..21
                  Parser/TokenHandler/KeywordTokenHandler.php on lines 1..21

                  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 92.

                  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 4 locations. Consider refactoring.
                  Open

                  <?php
                  
                  namespace Phug\Parser\TokenHandler;
                  
                  use Phug\Lexer\Token\BlockToken;
                  Severity: Major
                  Found in Parser/TokenHandler/BlockTokenHandler.php and 3 other locations - About 35 mins to fix
                  Parser/TokenHandler/ConditionalTokenHandler.php on lines 1..21
                  Parser/TokenHandler/KeywordTokenHandler.php on lines 1..21
                  Parser/TokenHandler/WhenTokenHandler.php on lines 1..21

                  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 92.

                  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 4 locations. Consider refactoring.
                  Open

                  <?php
                  
                  namespace Phug\Parser\TokenHandler;
                  
                  use Phug\Lexer\Token\ConditionalToken;
                  Severity: Major
                  Found in Parser/TokenHandler/ConditionalTokenHandler.php and 3 other locations - About 35 mins to fix
                  Parser/TokenHandler/BlockTokenHandler.php on lines 1..21
                  Parser/TokenHandler/KeywordTokenHandler.php on lines 1..21
                  Parser/TokenHandler/WhenTokenHandler.php on lines 1..21

                  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 92.

                  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

                  Function __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct($options = null)
                      {
                          $this->setOptionsDefaults($options ?: [], [
                              'lexer_class_name'        => Lexer::class,
                              'parser_state_class_name' => State::class,
                  Severity: Minor
                  Found in Parser.php - About 35 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

                  Function handleAttributeToken has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleAttributeToken(AttributeToken $token, State $state)
                      {
                          $this->createElementNodeIfMissing($token, $state);
                  
                          /** @var AttributeNode $node */
                  Severity: Minor
                  Found in Parser/TokenHandler/AttributeTokenHandler.php - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language