martin-helmich/typo3-typoscript-parser

View on GitHub

Showing 24 of 51 total issues

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

<?php declare(strict_types=1);

namespace Helmich\TypoScriptParser\Parser;

use ArrayObject;
Severity: Minor
Found in src/Parser/Parser.php - About 4 hrs to fix

    Function tokenizeString has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public function tokenizeString(string $inputString): array
        {
            $inputString = $this->preprocessor->preprocess($inputString);
    
            $tokens = new TokenStreamBuilder();
    Severity: Minor
    Found in src/Tokenizer/Tokenizer.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

    Method parseCondition has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function parseCondition(ParserState $state): void
        {
            if ($state->context()->depth() !== 0) {
                throw new ParseError(
                    'Found condition statement inside nested assignment.',
    Severity: Major
    Found in src/Parser/Parser.php - About 2 hrs to fix

      File Tokenizer.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Helmich\TypoScriptParser\Tokenizer;
      Severity: Minor
      Found in src/Tokenizer/Tokenizer.php - About 2 hrs to fix

        Method tokenizeBinaryObjectOperation has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function tokenizeBinaryObjectOperation(TokenStreamBuilder $tokens, array $matches, int $currentLine): void
            {
                $tokens->append(
                    $this->getTokenTypeForBinaryOperator($matches[3]),
                    $matches[3],
        Severity: Minor
        Found in src/Tokenizer/Tokenizer.php - About 1 hr to fix

          Method tokenizeString has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function tokenizeString(string $inputString): array
              {
                  $inputString = $this->preprocessor->preprocess($inputString);
          
                  $tokens = new TokenStreamBuilder();
          Severity: Minor
          Found in src/Tokenizer/Tokenizer.php - About 1 hr to fix

            Method printStatementList has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
                {
                    $indent = $this->getIndent($nesting);
                    $count  = count($statements);
            
            
            Severity: Minor
            Found in src/Parser/Printer/PrettyPrinter.php - About 1 hr to fix

              Method parseToken has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function parseToken(ParserState $state): void
                  {
                      switch ($state->token()->getType()) {
                          case TokenInterface::TYPE_OBJECT_IDENTIFIER:
                              $objectPath = $state->context()->append($state->token()->getValue());
              Severity: Minor
              Found in src/Parser/Parser.php - About 1 hr to fix

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

                    private function parseCondition(ParserState $state): void
                    {
                        if ($state->context()->depth() !== 0) {
                            throw new ParseError(
                                'Found condition statement inside nested assignment.',
                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

                Function printStatementList has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
                    {
                        $indent = $this->getIndent($nesting);
                        $count  = count($statements);
                
                
                Severity: Minor
                Found in src/Parser/Printer/PrettyPrinter.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 parseNestedStatements has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function parseNestedStatements(ParserState $state, ?int $startLine = null): void
                    {
                        $startLine  = $startLine ?: $state->token()->getLine();
                        $statements = new ArrayObject();
                        $subContext = $state->withStatements($statements);
                Severity: Minor
                Found in src/Parser/Parser.php - About 1 hr to fix

                  Method parseAssignment has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function parseAssignment(ParserState $state): void
                      {
                          switch ($state->token(2)->getType()) {
                              case TokenInterface::TYPE_OBJECT_CONSTRUCTOR:
                                  $state->statements()->append($this->builder->op()->objectCreation(
                  Severity: Minor
                  Found in src/Parser/Parser.php - About 1 hr to fix

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

                        private function parseToken(ParserState $state): void
                        {
                            switch ($state->token()->getType()) {
                                case TokenInterface::TYPE_OBJECT_IDENTIFIER:
                                    $objectPath = $state->context()->append($state->token()->getValue());
                    Severity: Minor
                    Found in src/Parser/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 parseNestedStatements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function parseNestedStatements(ParserState $state, ?int $startLine = null): void
                        {
                            $startLine  = $startLine ?: $state->token()->getLine();
                            $statements = new ArrayObject();
                            $subContext = $state->withStatements($statements);
                    Severity: Minor
                    Found in src/Parser/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 tokenizeBinaryObjectOperation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function tokenizeBinaryObjectOperation(TokenStreamBuilder $tokens, array $matches, int $currentLine): void
                        {
                            $tokens->append(
                                $this->getTokenTypeForBinaryOperator($matches[3]),
                                $matches[3],
                    Severity: Minor
                    Found in src/Tokenizer/Tokenizer.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 printConditionalStatement has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        private function printConditionalStatement(OutputInterface $output, int $nesting, ConditionalStatement $statement, bool $hasNext = false, bool $hasPrevious = false): void
                    Severity: Minor
                    Found in src/Parser/Printer/PrettyPrinter.php - About 35 mins to fix

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

                          public function __construct(string $type, string $value, int $line, int $column = 1, array $patternMatches = [])
                      Severity: Minor
                      Found in src/Tokenizer/Token.php - About 35 mins to fix

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

                            private function parseIncludeOptionals(string $optional, TokenInterface $token): array
                            {
                                if (!preg_match_all('/((?<key>[a-z]+)="(?<value>[^"]*)\s*)+"/', $optional, $matches)) {
                                    return [null, null];
                                }
                        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

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

                            private function tokenizeObjectOperation(
                                TokenStreamBuilder $tokens,
                                MultilineTokenBuilder $state,
                                ScannerLine $line
                            ): bool {
                        Severity: Minor
                        Found in src/Tokenizer/Tokenizer.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 normalized has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function normalized(): TokenStream
                            {
                                $filteredTokens = [];
                        
                                $maxLine = 0;
                        Severity: Minor
                        Found in src/Parser/TokenStream.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