rhosocial/yii2-base-models

View on GitHub

Showing 35 of 293 total issues

Function enabledFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
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 - 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

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

    public function deleteChildren()
    {
        $children = $this->children;
        if (empty($children)) {
            return true;
Severity: Minor
Found in traits/SelfBlameableTrait.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

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

    public function onDeleteChildren($event): bool
    {
        $sender = $event->sender;
        /* @var $sender static */
        if (empty($sender->parentAttribute) || !is_string($sender->parentAttribute)) {
Severity: Minor
Found in traits/SelfBlameableTrait.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

Function insertRelation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function insertRelation($relation, ?Connection $connection = null): bool
    {
        if (!($relation instanceof static)) {
            return false;
        }
Severity: Minor
Found in traits/UserRelationTrait.php - About 35 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 setIPAddress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function setIPAddress(?string $ipAddress): int|string|null
    {
        if (!$ipAddress || !$this->enableIP) {
            return null;
        }
Severity: Minor
Found in traits/IPTrait.php - About 35 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 unregister has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function unregister(): bool
    {
        if ($this->getIsNewRecord()) {
            return false;
        }
Severity: Minor
Found in traits/RegistrationTrait.php - About 35 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 too many return statements within this method.
Open

        return false;
Severity: Major
Found in traits/BlameableTrait.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return null;
    Severity: Major
    Found in traits/IPTrait.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                          return $this->getIPv6Address();
      Severity: Major
      Found in traits/IPTrait.php - About 30 mins to fix

        Function removeRelation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function removeRelation($relation, Connection $connection = null)
            {
                if (!($relation instanceof static) || $relation->getIsNewRecord()) {
                    return false;
                }
        Severity: Minor
        Found in traits/UserRelationTrait.php - About 25 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 bear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function bear(array $config = []): false|static|null
            {
                if (!$this->parentAttribute) {
                    throw new InvalidConfigException("Parent Attribute Not Determined.");
                }
        Severity: Minor
        Found in traits/SelfBlameableTrait.php - About 25 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 getBlameableAttributeRules has a Cognitive Complexity of 6 (exceeds 5 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 25 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 onReadAtChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function onReadAtChanged($event): void
            {
                $sender = $event->sender;
                /* @var $sender static */
                $raAttribute = $sender->readAtAttribute;
        Severity: Minor
        Found in traits/MessageTrait.php - About 25 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 setUpdater has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setUpdater(mixed $updater): bool|string
            {
                if (!is_string($this->updatedByAttribute) || empty($this->updatedByAttribute)) {
                    return false;
                }
        Severity: Minor
        Found in traits/BlameableTrait.php - About 25 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 removeIfExpired has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function removeIfExpired(): bool
            {
                if ($this->getIsExpired() && !$this->getIsNewRecord()) {
                    if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
                        call_user_func($this->expiredRemovingCallback, $this);
        Severity: Minor
        Found in traits/TimestampTrait.php - About 25 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

        Severity
        Category
        Status
        Source
        Language