yiisoft/yii2

View on GitHub
framework/db/SqlTokenizer.php

Summary

Maintainability
A
2 hrs
Test Coverage

The class SqlTokenizer has an overall complexity of 54 which is very high. The configured complexity threshold is 50.
Open

abstract class SqlTokenizer extends Component
{
    /**
     * @var string SQL code.
     */
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

Function tokenize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function tokenize()
    {
        $this->length = mb_strlen($this->sql, 'UTF-8');
        $this->offset = 0;
        $this->_substrings = [];
Severity: Minor
Found in framework/db/SqlTokenizer.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 tokenizeOperator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function tokenizeOperator(&$length)
    {
        if (!$this->isOperator($length, $content)) {
            return false;
        }
Severity: Minor
Found in framework/db/SqlTokenizer.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

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

    protected function startsWithAnyLongest(array &$with, $caseSensitive, &$length = null, &$content = null)
    {
        if (empty($with)) {
            return false;
        }
Severity: Minor
Found in framework/db/SqlTokenizer.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 using undefined variables such as '$length' which will lead to PHP notices.
Open

            if ($this->tokenizeOperator($length) || $this->tokenizeDelimitedString($length)) {
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

        if (!$this->isOperator($length, $content)) {
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$length' which will lead to PHP notices.
Open

            if ($this->isWhitespace($length) || $this->isComment($length)) {
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

            'content' => is_string($content) ? $content : $this->_buffer,
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$length' which will lead to PHP notices.
Open

            if ($this->isWhitespace($length) || $this->isComment($length)) {
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$length' which will lead to PHP notices.
Open

                $this->advance($length);
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

        $isStringLiteral = !$isIdentifier && $this->isStringLiteral($length, $content);
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

            'content' => is_string($content) ? $content : $this->_buffer,
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

        $isIdentifier = $this->isIdentifier($length, $content);
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

                    'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$length' which will lead to PHP notices.
Open

            if ($this->tokenizeOperator($length) || $this->tokenizeDelimitedString($length)) {
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$length' which will lead to PHP notices.
Open

                $this->advance($length);
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

            'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

        $isKeyword = $this->isKeyword($this->_buffer, $content);
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$content' which will lead to PHP notices.
Open

            'content' => is_string($content) ? $content : $this->substring($length),
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

The method substring has a boolean flag argument $caseSensitive, which is a certain sign of a Single Responsibility Principle violation.
Open

    protected function substring($length, $caseSensitive = true, $offset = null)
Severity: Minor
Found in framework/db/SqlTokenizer.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '95', column '34').
Open

        $this->_tokenStack = new \SplStack();
Severity: Minor
Found in framework/db/SqlTokenizer.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

There are no issues that match your filters.

Category
Status