yiisoft/yii2

View on GitHub

Showing 2,366 of 2,366 total issues

Function validation has a Cognitive Complexity of 194 (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 3 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 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 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 1380..1419

    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 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 1324..1363

    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

    File BaseHtml.php has 901 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

      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 BaseActiveRecord.php has 826 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

        File Formatter.php has 800 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 Request.php has 778 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 validation has 362 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 QueryBuilder.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/db/QueryBuilder.php - About 1 day to fix

                Similar blocks of code found in 2 locations. 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/mssql/conditions/InConditionBuilder.php and 1 other location - About 1 day to fix
                framework/db/sqlite/conditions/InConditionBuilder.php on lines 1..58

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

                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

                <?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/sqlite/conditions/InConditionBuilder.php and 1 other location - About 1 day to fix
                framework/db/mssql/conditions/InConditionBuilder.php on lines 1..58

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

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

                      QueryBuilder has 75 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class QueryBuilder extends \yii\base\BaseObject
                      {
                          /**
                           * The prefix for automatically generated query binding parameters.
                           */
                      Severity: Major
                      Found in framework/db/QueryBuilder.php - About 1 day to fix

                        BaseHtml has 73 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

                            File BaseConsole.php has 568 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/BaseConsole.php - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language