hnhdigital-os/laravel-model-filter

View on GitHub

Showing 194 of 194 total issues

The method getCurrentSearchQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return ['filters' => [], 'rows' => ''];
        }
Severity: Minor
Found in src/Traits/ControllerTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method getFilterAttributes uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    unset($filters[$key]);
                }
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method showSearchAppliedFilters() has an NPath complexity of 244. The configured NPath complexity threshold is 200.
Open

    protected static function showSearchAppliedFilters(&$tbody, &$search_request, $result, $model, $column_span = 1)
    {
        self::pagination($result, $search_request);

        // Applied filters
Severity: Minor
Found in src/Traits/ControllerTrait.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

Avoid unused local variables such as '$query_connections'.
Open

                $query_connections = [];
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method applyFilterAttributeArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $method_argument = [$attribute.$method_argument];
            }
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid unused parameters such as '$value2'.
Open

    private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

The method getCurrentSearchQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                if (isset($unattached_method_source)) {
                    return $model->$unattached_method_source();
                }

Severity: Minor
Found in src/Traits/ControllerTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method getSearchAppliedFilters() has an NPath complexity of 360. The configured NPath complexity threshold is 200.
Open

    protected static function getSearchAppliedFilters($controller_name, $distinct_session = '', $use_session = false)
    {

        // Filter provided.
        if (is_array($use_session)) {
Severity: Minor
Found in src/Traits/ControllerTrait.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

The method processAttributeFilter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                    } else {
                        if (is_array($arguments)) {
                            if (($method === 'whereIn' || $method === 'whereNotIn')
                                && empty($arguments[0])) {
                                break;
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method processAttributeFilter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else {
                            $query = $query->$method($attribute.$arguments);
                        }
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method checkSearchResults uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $template = 'No <strong>%s</strong> exist';
                if (isset($config['attached_no_filter_no_results']) && $config['search_tab'] == $config['attached_tab']) {
                    $template = $config['attached_no_filter_no_results'];
                } elseif (isset($config['unattached_no_filter_no_results']) && $config['search_tab'] != $config['attached_tab']) {
Severity: Minor
Found in src/Traits/ControllerTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid unused local variables such as '$filter_list'.
Open

                        $filter_list = '';
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method processAttributeFilter() has an NPath complexity of 7682. The configured NPath complexity threshold is 200.
Open

    private static function processAttributeFilter($query, $filter_setting, $filter_requests)
    {
        $model = (new static());
        foreach ($filter_requests as $filter_request) {
            // Clean inputs
Severity: Minor
Found in src/Traits/ModelTrait.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

The method scopeModelJoin uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $table = $relation->getTable();
            }
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method compose uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $column1 = $view_data['filter_settings']['name'];
            $column2 = Html::select()->name($view_data['filter_name'].'_operator[]')->addClass('search-operator form-control')
                ->style('width:100%;')->addOptionsArray($view_data['operator_options'], 'value', 'name', $view_data['filter'][0]);
            $column3 = Html::select()->name($view_data['filter_name'].'_value1[]')->addClass('search-value1 form-control init-select2')
Severity: Minor
Found in src/Composers/SearchFilterList.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid unused local variables such as '$available_attributes'.
Open

                    $available_attributes = array_keys($model->attribute_rules);
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method validateOperators() has an NPath complexity of 234. The configured NPath complexity threshold is 200.
Open

    private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
    {
        // No space search.
        if (array_has($filter_setting, 'phone_search')) {
            $value1_numeric = str_replace(' ', '', $value1);
Severity: Minor
Found in src/Traits/ModelTrait.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

The method validateOperators uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $value1 = [];
                }
Severity: Minor
Found in src/Traits/ModelTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method runStandardSubSearch uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $search_request_path .= $model->uuid.'/';
                }
Severity: Minor
Found in src/Traits/ControllerTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method getCurrentSearchDetails() has an NPath complexity of 16777216. The configured NPath complexity threshold is 200.
Open

    public function getCurrentSearchDetails($use_session, $settings, $options, $search_name)
    {
        if (request()->ajax()) {
            $settings_data = request()->all();
        } else {
Severity: Minor
Found in src/Traits/ControllerTrait.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