j84reginato/my-eval

View on GitHub
src/Parsing/Parser.php

Summary

Maintainability
D
1 day
Test Coverage

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

<?php

declare(strict_types=1);

namespace MyEval\Parsing;
Severity: Minor
Found in src/Parsing/Parser.php - About 4 hrs to fix

    Parser has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Parser
    {
        use Numeric;
    
        /**
    Severity: Minor
    Found in src/Parsing/Parser.php - About 2 hrs to fix

      Method processToken has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function processToken(Token $token): void
          {
              $node = Node::factory($token);
      
              switch (get_class($node)) {
      Severity: Minor
      Found in src/Parsing/Parser.php - About 2 hrs to fix

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

            private function processToken(Token $token): void
            {
                $node = Node::factory($token);
        
                switch (get_class($node)) {
        Severity: Minor
        Found in src/Parsing/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

        Function isUnary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function isUnary(Node $node, ?Node $lastNode): bool
            {
                if (!$node instanceof InfixExpressionNode) {
                    return false;
                }
        Severity: Minor
        Found in src/Parsing/Parser.php - About 55 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 populateNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function populateNode(AbstractOperatorNode $node): Node
            {
                if ($node instanceof FunctionNode) {
                    throw new DelimeterMismatchException($node->operator);
                }
        Severity: Minor
        Found in src/Parsing/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

        Avoid too many return statements within this method.
        Open

                    return true;
        Severity: Major
        Found in src/Parsing/Parser.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return true;
          Severity: Major
          Found in src/Parsing/Parser.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in src/Parsing/Parser.php - About 30 mins to fix

              Function handleCloseParenthesis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function handleCloseParenthesis(): void
                  {
                      // Flag, checking for mismatching parentheses.
                      $clean = false;
              
              
              Severity: Minor
              Found in src/Parsing/Parser.php - About 25 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 handleInfixOperator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function handleInfixOperator(InfixExpressionNode $node, Token $token, ?Node $lastNode): void
                  {
                      // Check for unary minus and unary plus.
                      if ($this->isUnary($node, $lastNode)) {
                          // Unary +, just ignore it.
              Severity: Minor
              Found in src/Parsing/Parser.php - About 25 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

              There are no issues that match your filters.

              Category
              Status