rhosocial/yii2-base-models

View on GitHub

Showing 293 of 293 total issues

The method register() has an NPath complexity of 446. The configured NPath complexity threshold is 200.
Open

    public function register(?array $associatedModels = [], array|string|null $authRoles = []): bool
    {
        if (!$this->getIsNewRecord()) {
            return false;
        }
Severity: Minor
Found in traits/RegistrationTrait.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 using static access to class '\Yii' in method 'register'.
Open

            Yii::warning($ex->getMessage(), __METHOD__);
Severity: Minor
Found in traits/RegistrationTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method enabledFields() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
Open

    public function enabledFields(): array
    {
        $fields = parent::enabledFields();
        if (is_string($this->createdByAttribute) && !empty($this->createdByAttribute)) {
            $fields[] = $this->createdByAttribute;
Severity: Minor
Found in traits/BlameableTrait.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method register() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
Open

    public function register(?array $associatedModels = [], array|string|null $authRoles = []): bool
    {
        if (!$this->getIsNewRecord()) {
            return false;
        }
Severity: Minor
Found in traits/RegistrationTrait.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method onReadAtChanged() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public function onReadAtChanged($event): void
    {
        $sender = $event->sender;
        /* @var $sender static */
        $raAttribute = $sender->readAtAttribute;
Severity: Minor
Found in traits/MessageTrait.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method compositeGUIDs() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
Open

    public static function compositeGUIDs(mixed $models): array|string|null
    {
        if (empty($models)) {
            return null;
        }
Severity: Minor
Found in traits/GUIDTrait.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

Only one argument is allowed per line in a multi-line function call
Open

        return array_merge($rules, $this->getRemarkRules(),
Severity: Minor
Found in traits/UserRelationTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

                        ('Registration Error(s) Occurred: Associated Models Save Failed.', $model->getErrors());
Severity: Minor
Found in traits/RegistrationTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 141 characters
Open

        if (is_string($this->updatedByAttribute) && $this->guidAttribute != $this->updatedByAttribute && !empty($this->updatedByAttribute)) {
Severity: Minor
Found in traits/BlameableTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 129 characters
Open

        if (isset($event->changedAttributes[$raAttribute]) && $event->changedAttributes[$raAttribute] != $sender->$raAttribute) {
Severity: Minor
Found in traits/MessageTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 155 characters
Open

            !is_string($this->passwordHashAttribute) || empty($this->passwordHashAttribute) || $this->validatePassword($this->getEmptyPasswordSpecialty());
Severity: Minor
Found in traits/PasswordTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 151 characters
Open

 *         $this->multiBlamesClass = UserRelationGroup::class; // if you need relation group feature, `$multiBlamesClass` property should be specified.

Arguments with default values must be at the end of the argument list
Open

        public int $timeType = 0,

Line exceeds 120 characters; contains 161 characters
Open

            if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
Severity: Minor
Found in traits/TimestampTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

     * @var boolean indicates whether throw exception or not when restriction occurred on updating or deleting operation.

Line exceeds 120 characters; contains 174 characters
Open

            return date('Y-m-d H:i:s', strtotime(($offset >= 0 ? "+$offset" : $offset) . " seconds", is_string($time) ? strtotime($time) : (is_int($time) ? $time : time())));
Severity: Minor
Found in traits/TimestampTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 125 characters
Open

        if (array_key_exists($name, $this->subsidiaryMap) && array_key_exists('class', (array)$this->subsidiaryMap[$name])) {
Severity: Minor
Found in traits/SubsidiaryTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 151 characters
Open

 *         $this->multiBlamesClass = UserRelationGroup::class; // if you need relation group feature, `$multiBlamesClass` property should be specified.

Line exceeds 120 characters; contains 132 characters
Open

        if (isset($event->changedAttributes[$reaAttribute]) && $event->changedAttributes[$reaAttribute] != $sender->$reaAttribute) {
Severity: Minor
Found in traits/MessageTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 141 characters
Open

        if (is_string($reaAttribute) && !$sender->isInitDatetime($sender->$raAttribute) && $sender->isInitDatetime($sender->$reaAttribute)) {
Severity: Minor
Found in traits/MessageTrait.php by phpcodesniffer
Severity
Category
Status
Source
Language