rhosocial/yii2-base-models

View on GitHub

Showing 293 of 293 total issues

Avoid using short method names like EntityQueryTrait::id(). The configured minimum method name length is 3.
Open

    public function id(mixed $id, false|string $like = false): static
    {
        /* @var $this ActiveQuery */
        $model = $this->noInitModel;
        return $this->likeCondition((string)$id, $model->idAttribute, $like);
Severity: Minor
Found in traits/EntityQueryTrait.php by phpmd

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

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

Avoid using short method names like BlameableTrait::on(). The configured minimum method name length is 3.
Open

    public abstract function on($name, $handler, $data = null, $append = true);
Severity: Minor
Found in traits/BlameableTrait.php by phpmd

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

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

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

    public function addSubsidiaryClass(?string $name, array|string|null $config): bool
    {
        if (empty($name)) {
            throw new InvalidConfigException('Subsidiary name not specified.');
        }
Severity: Minor
Found in traits/SubsidiaryTrait.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

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

            return $behaviors;
Severity: Minor
Found in traits/OperatorTrait.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 '$behaviors' which will lead to PHP notices.
Open

            $behaviors[] = [
Severity: Minor
Found in traits/OperatorTrait.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

Method updateChildren has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function updateChildren($value = false)
    {
        $children = $this->getOldChildren();
        if (empty($children)) {
            return true;
Severity: Minor
Found in traits/SelfBlameableTrait.php - About 1 hr to fix

    Function getIPAddress has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getIPAddress(): ?string
        {
            if ($this->enableIP <= 0 || $this->enableIP > 3) {
                return null;
            }
    Severity: Minor
    Found in traits/IPTrait.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 addOrCreateBlame has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addOrCreateBlame(&$blame = null, $user = null)
        {
            if (!is_string($this->multiBlamesClass)) {
                throw new InvalidConfigException
                ('$multiBlamesClass must be specified if you want to use multiple blameable features.');
    Severity: Minor
    Found in traits/MultipleBlameableTrait.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

    Method getContentRules has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getContentRules(): array
        {
            if (!$this->contentAttribute) {
                return [];
            }
    Severity: Minor
    Found in traits/BlameableTrait.php - About 1 hr to fix

      Method getBlameableAttributeRules has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getBlameableAttributeRules()
          {
              $rules = [];
              // 创建者和上次修改者由 BlameableBehavior 负责,因此标记为安全。
              if (!is_string($this->createdByAttribute) || empty($this->createdByAttribute)) {
      Severity: Minor
      Found in traits/BlameableTrait.php - About 1 hr to fix

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

            protected function resetConfirmation(): void
            {
                $contentAttribute = $this->contentAttribute;
                if (empty($contentAttribute)) {
                    return;
        Severity: Minor
        Found in traits/ConfirmationTrait.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

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

            public function getContentRules(): array
            {
                if (!$this->contentAttribute) {
                    return [];
                }
        Severity: Minor
        Found in traits/BlameableTrait.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

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

            public function getIdRules(): array
            {
                if (!$this->idAttribute) {
                    return [];
                }
        Severity: Minor
        Found in traits/IDTrait.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

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

            public static function gets($keys = null)
            {
                $noInitModel = static::buildNoInitModel();
                $query = static::find();
                if ($keys == null) {
        Severity: Minor
        Found in traits/MetaTrait.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 $id. Configured minimum length is 3.
        Open

            public function id(mixed $id, false|string $like = false): static
        Severity: Minor
        Found in traits/EntityQueryTrait.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

        A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 18.
        Open

        <?php
        Severity: Minor
        Found in traits/config/GUIDConfig.php by phpcodesniffer

        A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 18.
        Open

        <?php

        A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 18.
        Open

        <?php
        Severity: Minor
        Found in traits/config/IDConfig.php by phpcodesniffer

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

            public static function findOneById(int|string|null $id, bool $throwException = true, mixed $identity = null): ?static
        Severity: Minor
        Found in traits/BlameableTrait.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

        A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 18.
        Open

        <?php
        Severity
        Category
        Status
        Source
        Language