rhosocial/yii2-base-models

View on GitHub

Showing 35 of 293 total issues

File BlameableTrait.php has 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *  _   __ __ _____ _____ ___  ____  _____
 * | | / // // ___//_  _//   ||  __||_   _|
Severity: Minor
Found in traits/BlameableTrait.php - About 6 hrs to fix

    File UserRelationTrait.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     *  _   __ __ _____ _____ ___  ____  _____
     * | | / // // ___//_  _//   ||  __||_   _|
    Severity: Minor
    Found in traits/UserRelationTrait.php - About 4 hrs to fix

      File SelfBlameableTrait.php has 354 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      /**
       *  _   __ __ _____ _____ ___  ____  _____
       * | | / // // ___//_  _//   ||  __||_   _|
      Severity: Minor
      Found in traits/SelfBlameableTrait.php - About 4 hrs to fix

        Function register has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function register(?array $associatedModels = [], array|string|null $authRoles = []): bool
            {
                if (!$this->getIsNewRecord()) {
                    return false;
                }
        Severity: Minor
        Found in traits/RegistrationTrait.php - About 3 hrs 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

        File MultipleBlameableTrait.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /**
         *  _   __ __ _____ _____ ___  ____  _____
         * | | / // // ___//_  _//   ||  __||_   _|
        Severity: Minor
        Found in traits/MultipleBlameableTrait.php - About 2 hrs to fix

          Method register has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Function compositeGUIDs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function compositeGUIDs(mixed $models): array|string|null
                {
                    if (empty($models)) {
                        return null;
                    }
            Severity: Minor
            Found in traits/GUIDTrait.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 updateChildren has a Cognitive Complexity of 12 (exceeds 5 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

            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 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

            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

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

                      public function onUpdateChildren($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 buildRelation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected static function buildRelation($user, $other)
                      {
                          $relationQuery = static::find()->initiators($user)->recipients($other);
                          $noInit = $relationQuery->noInitModel;
                          $relation = $relationQuery->one();
                  Severity: Minor
                  Found in traits/UserRelationTrait.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

                  Severity
                  Category
                  Status
                  Source
                  Language