yiisoft/yii2

View on GitHub

Showing 787 of 2,468 total issues

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

    public function validateAttribute($model, $attribute)
    {
        $value = $model->$attribute;
        if (is_array($value)) {
            $this->addError($model, $attribute, Yii::t('yii', '{attribute} is invalid.'));
Severity: Minor
Found in framework/validators/CompareValidator.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 canSetProperty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
    {
        if (method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name)) {
            return true;
        } elseif ($checkBehaviors) {
Severity: Minor
Found in framework/base/Component.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 createUrl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function createUrl($page, $pageSize = null, $absolute = false)
    {
        $page = (int) $page;
        $pageSize = (int) $pageSize;
        if (($params = $this->params) === null) {
Severity: Minor
Found in framework/data/Pagination.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 setSort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function setSort($value)
    {
        parent::setSort($value);
        if ($this->query instanceof ActiveQueryInterface && ($sort = $this->getSort()) !== false) {
            /* @var $modelClass Model */
Severity: Minor
Found in framework/data/ActiveDataProvider.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 end has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function end()
    {
        if (!empty(self::$stack)) {
            $widget = array_pop(self::$stack);

Severity: Minor
Found in framework/base/Widget.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 resolvePathInfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function resolvePathInfo()
    {
        $pathInfo = $this->getUrl();

        if (($pos = strpos($pathInfo, '?')) !== false) {
Severity: Minor
Found in framework/web/Request.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 loadFallbackMessages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadFallbackMessages($category, $fallbackLanguage, $messages, $originalMessageFile)
    {
        $fallbackMessageFile = $this->getMessageFilePath($category, $fallbackLanguage);
        $fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile);

Severity: Minor
Found in framework/i18n/PhpMessageSource.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 init has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function init()
    {
        parent::init();

        if (!$this->ipv4 && !$this->ipv6) {
Severity: Minor
Found in framework/validators/IpValidator.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 checkbox has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkbox($options = [], $enclosedByLabel = true)
    {
        if ($this->form->validationStateOn === ActiveForm::VALIDATION_STATE_ON_INPUT) {
            $this->addErrorClassIfNeeded($options);
        }
Severity: Minor
Found in framework/widgets/ActiveField.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 radio has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function radio($options = [], $enclosedByLabel = true)
    {
        if ($this->form->validationStateOn === ActiveForm::VALIDATION_STATE_ON_INPUT) {
            $this->addErrorClassIfNeeded($options);
        }
Severity: Minor
Found in framework/widgets/ActiveField.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

Method saveMessagesToPO has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected function saveMessagesToPO($messages, $dirName, $overwrite, $removeUnused, $sort, $catalog, $markUnused)
Severity: Major
Found in framework/console/controllers/MessageController.php - About 50 mins to fix

    Method saveMessagesCategoryToPHP has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        protected function saveMessagesCategoryToPHP($messages, $fileName, $overwrite, $removeUnused, $sort, $category, $markUnused)
    Severity: Major
    Found in framework/console/controllers/MessageController.php - About 50 mins to fix

      Method saveMessagesToDb has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          protected function saveMessagesToDb($messages, $db, $sourceMessageTable, $messageTable, $removeUnused, $languages, $markUnused)
      Severity: Major
      Found in framework/console/controllers/MessageController.php - About 50 mins to fix

        Method addForeignKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
        Severity: Major
        Found in framework/db/Command.php - About 50 mins to fix

          Method addForeignKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
          Severity: Major
          Found in framework/db/oci/QueryBuilder.php - About 50 mins to fix

            Method addForeignKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
            Severity: Major
            Found in framework/db/QueryBuilder.php - About 50 mins to fix

              Method addForeignKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
              Severity: Major
              Found in framework/db/Migration.php - About 50 mins to fix

                Method addForeignKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
                Severity: Major
                Found in framework/db/sqlite/QueryBuilder.php - About 50 mins to fix

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

                      protected function checkAccessRecursive($user, $itemName, $params, $assignments)
                      {
                          if (!isset($this->items[$itemName])) {
                              return false;
                          }
                  Severity: Minor
                  Found in framework/rbac/PhpManager.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

                  Avoid deeply nested control flow statements.
                  Open

                                              if (in_array($previousToken, [T_OBJECT_OPERATOR, T_PAAMAYIM_NEKUDOTAYIM], true)) {
                                                  $matchedTokensCount = 0;
                                                  continue;
                                              }
                  Severity: Major
                  Found in framework/console/controllers/MessageController.php - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language