yiisoft/yii2

View on GitHub

Showing 2,235 of 2,235 total issues

Function validation has a Cognitive Complexity of 198 (exceeds 5 allowed). Consider refactoring.
Open

yii.validation = (function ($) {
    var pub = {
        isEmpty: function (value) {
            return value === null || value === undefined || ($.isArray(value) && value.length === 0) || value === '';
        },
Severity: Minor
Found in framework/assets/yii.validation.js - About 4 days 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    public function insert($table, $columns, &$params)
    {
        $schema = $this->db->getSchema();
        if (($tableSchema = $schema->getTableSchema($table)) !== null) {
            $columnSchemas = $tableSchema->columns;
Severity: Major
Found in framework/db/mysql/QueryBuilder.php and 1 other location - About 2 days to fix
framework/db/oci/QueryBuilder.php on lines 187..229

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 439.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    public function insert($table, $columns, &$params)
    {
        $schema = $this->db->getSchema();
        if (($tableSchema = $schema->getTableSchema($table)) !== null) {
            $columnSchemas = $tableSchema->columns;
Severity: Major
Found in framework/db/oci/QueryBuilder.php and 1 other location - About 2 days to fix
framework/db/mysql/QueryBuilder.php on lines 234..276

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 439.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File mimeTypes.php has 986 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * MIME types.
 *
 * This file contains most commonly used MIME types
Severity: Major
Found in framework/helpers/mimeTypes.php - About 2 days to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function asSize($value, $decimals = null, $options = [], $textOptions = [])
        {
            if ($value === null) {
                return $this->nullDisplay;
            }
    Severity: Major
    Found in framework/i18n/Formatter.php and 1 other location - About 2 days to fix
    framework/i18n/Formatter.php on lines 1323..1362

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 388.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
        {
            if ($value === null) {
                return $this->nullDisplay;
            }
    Severity: Major
    Found in framework/i18n/Formatter.php and 1 other location - About 2 days to fix
    framework/i18n/Formatter.php on lines 1379..1418

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 388.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function yii has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
    Open

    window.yii = (function ($) {
        var pub = {
            /**
             * List of JS or CSS URLs that can be loaded multiple times via AJAX requests.
             * Each item may be represented as either an absolute URL or a relative one.
    Severity: Minor
    Found in framework/assets/yii.js - About 2 days 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 BaseHtml.php has 876 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @link http://www.yiiframework.com/
     * @copyright Copyright (c) 2008 Yii Software LLC
     * @license http://www.yiiframework.com/license/
    Severity: Major
    Found in framework/helpers/BaseHtml.php - About 2 days to fix

      File QueryBuilder.php has 840 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * @link http://www.yiiframework.com/
       * @copyright Copyright (c) 2008 Yii Software LLC
       * @license http://www.yiiframework.com/license/
      Severity: Major
      Found in framework/db/QueryBuilder.php - About 2 days to fix

        File Formatter.php has 799 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * @link http://www.yiiframework.com/
         * @copyright Copyright (c) 2008 Yii Software LLC
         * @license http://www.yiiframework.com/license/
        Severity: Major
        Found in framework/i18n/Formatter.php - About 1 day to fix

          File BaseActiveRecord.php has 779 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * @link http://www.yiiframework.com/
           * @copyright Copyright (c) 2008 Yii Software LLC
           * @license http://www.yiiframework.com/license/
          Severity: Major
          Found in framework/db/BaseActiveRecord.php - About 1 day to fix

            Function validation has 363 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            yii.validation = (function ($) {
                var pub = {
                    isEmpty: function (value) {
                        return value === null || value === undefined || ($.isArray(value) && value.length === 0) || value === '';
                    },
            Severity: Major
            Found in framework/assets/yii.validation.js - About 1 day to fix

              File Request.php has 767 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * @link http://www.yiiframework.com/
               * @copyright Copyright (c) 2008 Yii Software LLC
               * @license http://www.yiiframework.com/license/
              Severity: Major
              Found in framework/web/Request.php - About 1 day to fix

                Function yii has 311 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                window.yii = (function ($) {
                    var pub = {
                        /**
                         * List of JS or CSS URLs that can be loaded multiple times via AJAX requests.
                         * Each item may be represented as either an absolute URL or a relative one.
                Severity: Major
                Found in framework/assets/yii.js - About 1 day to fix

                  File DbManager.php has 653 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * @link http://www.yiiframework.com/
                   * @copyright Copyright (c) 2008 Yii Software LLC
                   * @license http://www.yiiframework.com/license/
                  Severity: Major
                  Found in framework/rbac/DbManager.php - About 1 day to fix

                    Request has 76 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Request extends \yii\base\Request
                    {
                        /**
                         * The name of the HTTP header for sending CSRF token.
                         */
                    Severity: Major
                    Found in framework/web/Request.php - About 1 day to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          protected function buildCompositeInCondition($operator, $columns, $values, &$params)
                          {
                              $quotedColumns = [];
                              foreach ($columns as $i => $column) {
                                  $quotedColumns[$i] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column;
                      Severity: Major
                      Found in framework/db/sqlite/QueryBuilder.php and 1 other location - About 1 day to fix
                      framework/db/mssql/QueryBuilder.php on lines 347..369

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 257.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          protected function buildCompositeInCondition($operator, $columns, $values, &$params)
                          {
                              $quotedColumns = [];
                              foreach ($columns as $i => $column) {
                                  $quotedColumns[$i] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column;
                      Severity: Major
                      Found in framework/db/mssql/QueryBuilder.php and 1 other location - About 1 day to fix
                      framework/db/sqlite/QueryBuilder.php on lines 443..465

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 257.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      BaseHtml has 72 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class BaseHtml
                      {
                          /**
                           * @var string Regular expression used for attribute name validation.
                           * @since 2.0.12
                      Severity: Major
                      Found in framework/helpers/BaseHtml.php - About 1 day to fix

                        File MessageController.php has 577 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * @link http://www.yiiframework.com/
                         * @copyright Copyright (c) 2008 Yii Software LLC
                         * @license http://www.yiiframework.com/license/
                        Severity: Major
                        Found in framework/console/controllers/MessageController.php - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source