yiisoft/yii2

View on GitHub

Showing 787 of 2,467 total issues

Avoid deeply nested control flow statements.
Open

                        if ($carry === 0) {
                            break;
                        }
Severity: Major
Found in framework/i18n/Formatter.php - About 45 mins to fix

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

        protected function validateCondition($condition)
        {
            if (!is_array($condition)) {
                $this->addError($this->filterAttributeName, $this->parseErrorMessage('invalidFilter'));
                return;
    Severity: Minor
    Found in framework/data/DataFilter.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

    Consider simplifying this complex logical expression.
    Open

            if (
                $this->matchAction($action)
                && $this->matchRole($user)
                && $this->matchIP($request->getUserIP())
                && $this->matchVerb($request->getMethod())
    Severity: Major
    Found in framework/filters/AccessRule.php - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                  if (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) === $scriptName) {
                      $this->_scriptUrl = $_SERVER['SCRIPT_NAME'];
                  } elseif (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) === $scriptName) {
                      $this->_scriptUrl = $_SERVER['PHP_SELF'];
                  } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $scriptName) {
      Severity: Major
      Found in framework/web/Request.php - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                        if ($isArray) {
                            $params[$name] = (array)$params[$name];
                        } elseif (is_array($params[$name])) {
                            $isValid = false;
                        } elseif (
        Severity: Major
        Found in framework/web/Controller.php - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                              if (
                                  $message === false && $selector === 'other' ||
                                  strncmp($selector, '=', 1) === 0 && (int) mb_substr($selector, 1, mb_strlen($selector, $charset), $charset) === $arg ||
                                  $selector === 'one' && $arg - $offset == 1
                              ) {
          Severity: Major
          Found in framework/i18n/MessageFormatter.php - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                        if ($checkDateTimeInfo) {
                            $timestamp = new DateTime($value, new DateTimeZone($this->defaultTimeZone));
                            $info = date_parse($value);
                            return [
                                $timestamp,
            Severity: Major
            Found in framework/i18n/Formatter.php - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if ($date === false || ($errors !== false && ($errors['error_count'] || $errors['warning_count'])) || ($this->strictDateFormat && $date->format($format) !== $value)) {
                          return false;
                      }
              Severity: Major
              Found in framework/validators/DateValidator.php - About 40 mins to fix

                Function initEventHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    function initEventHandler($gridView, type, event, selector, callback)
                Severity: Minor
                Found in framework/assets/yii.gridView.js - About 35 mins to fix

                  Method formatOptionHelp has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      protected function formatOptionHelp($name, $required, $type, $defaultValue, $comment)
                  Severity: Minor
                  Found in framework/console/controllers/HelpController.php - About 35 mins to fix

                    Method truncate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public static function truncate($string, $length, $suffix = '...', $encoding = null, $asHtml = false)
                    Severity: Minor
                    Found in framework/helpers/BaseStringHelper.php - About 35 mins to fix

                      Method activeListInput has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          protected static function activeListInput($type, $model, $attribute, $items, $options = [])
                      Severity: Minor
                      Found in framework/helpers/BaseHtml.php - About 35 mins to fix

                        Method tokensMatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            private function tokensMatch(SqlToken $patternToken, SqlToken $token, $offset = 0, &$firstMatchIndex = null, &$lastMatchIndex = null)
                        Severity: Minor
                        Found in framework/db/SqlToken.php - About 35 mins to fix

                          Method matchPathname has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              private static function matchPathname($path, $basePath, $pattern, $firstWildcard, $flags)
                          Severity: Minor
                          Found in framework/helpers/BaseFileHelper.php - About 35 mins to fix

                            Method bindParam has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                public function bindParam($name, &$value, $dataType = null, $length = null, $driverOptions = null)
                            Severity: Minor
                            Found in framework/db/Command.php - About 35 mins to fix

                              Method extractColumnSize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  protected function extractColumnSize($column, $dbType, $precision, $scale, $length)
                              Severity: Minor
                              Found in framework/db/oci/Schema.php - About 35 mins to fix

                                Method extractColumnType has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    protected function extractColumnType($column, $dbType, $precision, $scale, $length)
                                Severity: Minor
                                Found in framework/db/oci/Schema.php - About 35 mins to fix

                                  Method buildBuckets has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      private function buildBuckets($models, $link, $viaModels = null, $viaQuery = null, $checkMultiple = true)
                                  Severity: Minor
                                  Found in framework/db/ActiveRelationTrait.php - About 35 mins to fix

                                    Method on has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        public static function on($class, $name, $handler, $data = null, $append = true)
                                    Severity: Minor
                                    Found in framework/base/Event.php - About 35 mins to fix

                                      Method hkdf has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          public function hkdf($algo, $inputKey, $salt = null, $info = null, $length = 0)
                                      Severity: Minor
                                      Found in framework/base/Security.php - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language