martin-helmich/typo3-typoscript-parser

View on GitHub

Showing 49 of 49 total issues

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

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

        public function condition(string $condition, array $if, array $else, int $line, bool $unterminated = false): ConditionalStatement
    Severity: Minor
    Found in src/Parser/AST/Builder.php - About 35 mins to fix

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

          public function __construct(string $condition, array $ifStatements, array $elseStatements, int $sourceLine, bool $unterminated = false)
      Severity: Minor
      Found in src/Parser/AST/ConditionalStatement.php - About 35 mins to fix

        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

        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) > 0)) {
                    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

        There must be one blank line after the namespace declaration
        Open

        namespace Helmich\TypoScriptParser\Parser\AST;

        Missing class import via use statement (line '150', column '23').
        Open

                    throw new \InvalidArgumentException("could not open file '$inputStream'");
        Severity: Minor
        Found in src/Tokenizer/Tokenizer.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Avoid too many return statements within this method.
        Open

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

          Missing class import via use statement (line '26', column '23').
          Open

                      throw new \InvalidArgumentException(
          Severity: Minor
          Found in src/Parser/AST/Statement.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '42', column '23').
          Open

                      throw new \InvalidArgumentException("could not open file '$stream'");
          Severity: Minor
          Found in src/Parser/Parser.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Avoid too many return statements within this method.
          Open

                          return TokenInterface::TYPE_OPERATOR_DELETE;
          Severity: Major
          Found in src/Tokenizer/Tokenizer.php - About 30 mins to fix

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

                private function parseValueOperation(ParserState $state): void
                {
                    switch ($state->token(1)->getType()) {
                        case TokenInterface::TYPE_OPERATOR_ASSIGNMENT:
                            $this->parseAssignment($state);
            Severity: Minor
            Found in src/Parser/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 parseTokens has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function parseTokens(array $tokens): array
                {
                    $stream = (new TokenStream($tokens))->normalized();
                    $state  = new ParserState($stream);
            
            
            Severity: Minor
            Found in src/Parser/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

            Avoid assigning values to variables in if clauses and the like (line '275', column '14').
            Open

                private function tokenizeMultilineComment(
                    TokenStreamBuilder $tokens,
                    MultilineTokenBuilder $state,
                    ScannerLine $line
                ): void {
            Severity: Minor
            Found in src/Tokenizer/Tokenizer.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid assigning values to variables in if clauses and the like (line '325', column '18').
            Open

                private function tokenizeSimpleStatements(TokenStreamBuilder $tokens, ScannerLine $line): bool
                {
                    $simpleTokens = [
                        self::TOKEN_COMMENT_ONELINE       => TokenInterface::TYPE_COMMENT_ONELINE,
                        self::TOKEN_NESTING_END           => TokenInterface::TYPE_BRACE_CLOSE,
            Severity: Minor
            Found in src/Tokenizer/Tokenizer.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid assigning values to variables in if clauses and the like (line '279', column '14').
            Open

                private function tokenizeMultilineComment(
                    TokenStreamBuilder $tokens,
                    MultilineTokenBuilder $state,
                    ScannerLine $line
                ): void {
            Severity: Minor
            Found in src/Tokenizer/Tokenizer.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid assigning values to variables in if clauses and the like (line '345', column '14').
            Open

                private function tokenizeObjectOperation(
                    TokenStreamBuilder $tokens,
                    MultilineTokenBuilder $state,
                    ScannerLine $line
                ): bool {
            Severity: Minor
            Found in src/Tokenizer/Tokenizer.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid assigning values to variables in if clauses and the like (line '108', column '18').
            Open

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

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            The method tokenizeBinaryObjectOperation() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
            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 by phpmd

            NPathComplexity

            Since: 0.1

            The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

            Example

            class Foo {
                function bar() {
                    // lots of complicated code
                }
            }

            Source https://phpmd.org/rules/codesize.html#npathcomplexity

            Severity
            Category
            Status
            Source
            Language