YetiForceCompany/YetiForceCRM

View on GitHub
app/Automatic/RulesPicklist.php

Summary

Maintainability
A
55 mins
Test Coverage
F
0%

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

    protected function check(array $items, array $params): bool
    {
        $condition = $params['condition'] ?? '';
        $b = false;
        foreach ($params['rules'] as $rule) {
Severity: Minor
Found in app/Automatic/RulesPicklist.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

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

        $b = false;
Severity: Minor
Found in app/Automatic/RulesPicklist.php by phpmd

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

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $condition = $params['condition'] ?? '';

Spaces must be used to indent lines; tabs are not allowed
Open

        return $b;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                $returnArr[] = $item['status'];

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int   $automation

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            $automation = $rule[static::AUTOMATION] ?? -1;

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param array $items

Spaces must be used to indent lines; tabs are not allowed
Open

            if ('or' === $condition && $b) {

Spaces must be used to indent lines; tabs are not allowed
Open

            if ('and' === $condition && !$b) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

                break;

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($params['rules'] as $rule) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Filter the array and get only the status.

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function check(array $items, array $params): bool

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function filterItems(array $items, int $automation = -1): array

Spaces must be used to indent lines; tabs are not allowed
Open

        return $returnArr;

Spaces must be used to indent lines; tabs are not allowed
Open

        $b = false;

Spaces must be used to indent lines; tabs are not allowed
Open

            $val = $rule['value'] ?? '';

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

            if (-1 === $automation || $item['automation'] === $automation) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * What value to choose from the plicklist for rules. -1 = All, 1 = Closed , 0 = Open.

Spaces must be used to indent lines; tabs are not allowed
Open

                break;

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        $returnArr = [];

Spaces must be used to indent lines; tabs are not allowed
Open

            $b = $this->checkOperator($operator, $this->filterItems($items, $automation), $val);

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    public const AUTOMATION = 'automation';

Spaces must be used to indent lines; tabs are not allowed
Open

            $operator = $rule['operator'] ?? '';

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($items as $item) {

There are no issues that match your filters.

Category
Status