vistart/yii2-models

View on GitHub

Showing 29 of 197 total issues

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

<?php

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

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

        public function register($associatedModels = [], $authRoles = [])
        {
            if (!$this->isNewRecord) {
                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 SelfBlameableTrait.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

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

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

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

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

              public function getIpAddress()
              {
                  if (!$this->enableIP) {
                      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 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

          Method getIdRules has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getIdRules()
              {
                  if ($this->idAttribute == false) {
                      return [];
                  }
          Severity: Minor
          Found in traits/IDTrait.php - About 1 hr to fix

            Method updateChildren has 31 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 getIdRules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getIdRules()
                  {
                      if ($this->idAttribute == false) {
                          return [];
                      }
              Severity: Minor
              Found in traits/IDTrait.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()
                  {
                      if (!$this->contentAttribute) {
                          return [];
                      }
              Severity: Minor
              Found in traits/BlameableTrait.php - About 1 hr to fix

                Function addOrCreateBlame has a Cognitive Complexity of 9 (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 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 resetConfirmation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function resetConfirmation()
                    {
                        $contentAttribute = $this->contentAttribute;
                        if (!$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 setIpAddress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function setIpAddress($ipAddress)
                    {
                        if (!$ipAddress || !$this->enableIP) {
                            return null;
                        }
                Severity: Minor
                Found in traits/IPTrait.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()
                    {
                        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 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 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 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

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

                    public function getRange()
                    {
                        $rangeAttribute = $this->rangeAttribute;
                        if (!is_string($rangeAttribute)) {
                            return null;
                Severity: Minor
                Found in traits/NotificationRangeTrait.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 onUpdateChildren has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function onUpdateChildren($event)
                    {
                        $sender = $event->sender;
                        if (!is_string($sender->parentAttribute)) {
                            return true;
                Severity: Minor
                Found in traits/SelfBlameableTrait.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

                Severity
                Category
                Status
                Source
                Language