railt/parser

View on GitHub

Showing 13 of 13 total issues

Function buildTree has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildTree(int $i = 0, array &$children = [])
    {
        $max = \count($this->trace);

        while ($i < $max) {
Severity: Minor
Found in src/Parser/Ast/Builder.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

Method buildTree has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function buildTree(int $i = 0, array &$children = [])
    {
        $max = \count($this->trace);

        while ($i < $max) {
Severity: Major
Found in src/Parser/Ast/Builder.php - About 2 hrs to fix

    Function renderAttributes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function renderAttributes(\DOMDocument $root, \DOMElement $node, $ast): void
        {
            $reflection = new \ReflectionObject($ast);
    
            /** @var \ReflectionProperty[] $properties */
    Severity: Minor
    Found in src/Parser/Dumper/XmlDumper.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

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

    class Parser implements ParserInterface
    {
        /**
         * @var LexerInterface
         */
    Severity: Minor
    Found in src/Parser/Parser.php - About 2 hrs to fix

      Function renderAsXml has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private function renderAsXml(\DOMDocument $root, $ast): \DOMElement
          {
              if ($ast instanceof LeafInterface) {
                  $token = $this->createElement($root, $this->getName($ast), $ast->getValue());
                  $this->renderAttributes($root, $token, $ast);
      Severity: Minor
      Found in src/Parser/Dumper/XmlDumper.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 extend has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function extend(string $ruleId, \Closure $then): ParserInterface
          {
              $maxId = \count($this->grammar->getRules()) - 1;
      
              $result = $then($this->grammar->fetch($ruleId), $maxId);
      Severity: Minor
      Found in src/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 renderAttributes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function renderAttributes(\DOMDocument $root, \DOMElement $node, $ast): void
          {
              $reflection = new \ReflectionObject($ast);
      
              /** @var \ReflectionProperty[] $properties */
      Severity: Minor
      Found in src/Parser/Dumper/XmlDumper.php - About 1 hr to fix

        Function unfold has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function unfold(): bool
            {
                while (0 < \count($this->todo)) {
                    $rule = \array_pop($this->todo);
        
        
        Severity: Minor
        Found in src/Parser/Parser.php - About 45 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

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

            public function __construct($name, $min, $max, $children, string $nodeId = null)
        Severity: Minor
        Found in src/Parser/Rule/Repetition.php - About 35 mins to fix

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

              private function backtrack(): bool
              {
                  $found = false;
          
                  do {
          Severity: Minor
          Found in src/Parser/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 false;
          Severity: Major
          Found in src/Parser/Parser.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $this->parseRepetition($current, $next);
            Severity: Major
            Found in src/Parser/Parser.php - About 30 mins to fix

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

                  protected function findChildren(RuleInterface $rule, string $name, int $depth): iterable
                  {
                      foreach ($rule->getChildren() as $child) {
                          if ($child->getName() === $name) {
                              yield $child;
              Severity: Minor
              Found in src/Parser/Ast/Rule.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

              Severity
              Category
              Status
              Source
              Language