timgws/QueryBuilderParser

View on GitHub

Showing 23 of 23 total issues

Avoid variables with short names like $v. Configured minimum length is 3.
Open

            return array_map(function ($v) {

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

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

    private function buildRequireArrayQuery($subclause, Builder $query)
    {
        if ($subclause['operator'] == 'IN') {
            $query->whereIn($subclause['to_value_column'], $subclause['value']);
        } elseif ($subclause['operator'] == 'NOT IN') {
Severity: Minor
Found in src/QueryBuilderParser/JoinSupportingQueryBuilderParser.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 makeArrayQueryBetween has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private function makeArrayQueryBetween(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
Severity: Minor
Found in src/QueryBuilderParser/QBPFunctions.php - About 35 mins to fix

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

        protected function makeQueryWhenArray(EloquentBuilder|Builder $query, stdClass $rule, array $sqlOperator, array $value, $condition)
    Severity: Minor
    Found in src/QueryBuilderParser/QBPFunctions.php - About 35 mins to fix

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

          private function makeArrayQueryIn(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
      Severity: Minor
      Found in src/QueryBuilderParser/QBPFunctions.php - About 35 mins to fix

        Expected 1 space after FUNCTION keyword; 0 found
        Open

                    function(Builder $query) use ($subclause) {

        PHP keywords must be lowercase; expected "callable" but found "Callable"
        Open

            public function clean($field, Callable $callback = null)

        Expected 0 spaces before closing bracket; 1 found
        Open

                if ( $operator == 'NOT BETWEEN' ) {

        The closing brace for the class must go on the next line after the body
        Open

        }

        Function closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

                }, $condition);

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

            private function buildSubclauseWithNull($subclause, Builder $query, $isNotNull = false)

        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

        Line exceeds 120 characters; contains 124 characters
        Open

                    return $this->buildSubclauseWithNull($subclause, $query, ($subclause['operator'] == 'NOT NULL' ? true : false));

        Line exceeds 120 characters; contains 127 characters
        Open

            private function makeArrayQueryBetween(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)

        Line exceeds 120 characters; contains 135 characters
        Open

            protected function makeQueryWhenArray(EloquentBuilder|Builder $query, stdClass $rule, array $sqlOperator, array $value, $condition)

        Line exceeds 120 characters; contains 122 characters
        Open

            private function makeArrayQueryIn(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)

        Line exceeds 120 characters; contains 128 characters
        Open

            protected function convertIncomingQBtoQuery(EloquentBuilder|Builder $query, stdClass $rule, $value, $queryCondition = 'AND')

        Expected 0 spaces before closing bracket; 1 found
        Open

                    return $query->whereNotBetween( $rule->field, $value, $condition );

        Space after opening parenthesis of function call prohibited
        Open

                    return $query->whereNotBetween( $rule->field, $value, $condition );

        Expected 0 spaces after opening bracket; 1 found
        Open

                if ( $operator == 'NOT BETWEEN' ) {

        The variable $require_array is not named in camelCase.
        Open

            private function buildSubclauseQuery($query, $rule, $value, $condition)
            {
                /*
                 * Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
                 * into on one that we can use inside the SQL query

        CamelCaseVariableName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name variables.

        Example

        class ClassName {
            public function doSomething() {
                $data_module = new DataModule();
            }
        }

        Source

        Severity
        Category
        Status
        Source
        Language