yiisoft/yii2

View on GitHub

Showing 787 of 2,467 total issues

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

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

        public function actionIndex($address = 'localhost')
        {
            $documentRoot = Yii::getAlias($this->docroot);
            $router = $this->router !== null ? Yii::getAlias($this->router) : null;
    
    
    Severity: Minor
    Found in framework/console/controllers/ServeController.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 evaluateAttributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function evaluateAttributes($event)
        {
            if (
                $this->skipUpdateOnClean
                && $event->name === ActiveRecord::EVENT_BEFORE_UPDATE
    Severity: Minor
    Found in framework/behaviors/AttributesBehavior.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 (!@rmdir($fullPath)) {
                                $error = error_get_last();
                                Yii::warning("Unable to remove directory '{$fullPath}': {$error['message']}", __METHOD__);
                            }
    Severity: Major
    Found in framework/caching/FileCache.php - About 45 mins to fix

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

          protected function setValue($key, $value, $duration)
          {
              $this->gc();
              $cacheFile = $this->getCacheFile($key);
              if ($this->directoryLevel > 0) {
      Severity: Minor
      Found in framework/caching/FileCache.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 matchIP has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function matchIP($ip)
          {
              if (empty($this->ips)) {
                  return true;
              }
      Severity: Minor
      Found in framework/filters/AccessRule.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 parseDocCommentTags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function parseDocCommentTags($reflection)
          {
              $comment = $reflection->getDocComment();
              $comment = "@description \n" . strtr(trim(preg_replace('/^\s*\**([ \t])?/m', '', trim($comment, '/'))), "\r", '');
              $parts = preg_split('/^\s*@/m', $comment, -1, PREG_SPLIT_NO_EMPTY);
      Severity: Minor
      Found in framework/console/Controller.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

      Method saveMessagesToPHP has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

            public static function select($prompt, $options = [], $default = null)
            {
                top:
                static::stdout("$prompt (" . implode(',', array_keys($options)) . ',?)'
                    . ($default !== null ? '[' . $default . ']' : '') . ': ');
        Severity: Minor
        Found in framework/helpers/BaseConsole.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 createDirectory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function createDirectory($path, $mode = 0775, $recursive = true)
            {
                if (is_dir($path)) {
                    return true;
                }
        Severity: Minor
        Found in framework/helpers/BaseFileHelper.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 htmlDecode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function htmlDecode($data, $valuesOnly = true)
            {
                $d = [];
                foreach ($data as $key => $value) {
                    if (!$valuesOnly && is_string($key)) {
        Severity: Minor
        Found in framework/helpers/BaseArrayHelper.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 confirm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function confirm($message, $default = false)
            {
                while (true) {
                    static::stdout($message . ' (yes|no) [' . ($default ? 'yes' : 'no') . ']:');
                    $input = trim(static::stdin());
        Severity: Minor
        Found in framework/helpers/BaseConsole.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 tokenizeOperator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function tokenizeOperator(&$length)
            {
                if (!$this->isOperator($length, $content)) {
                    return false;
                }
        Severity: Minor
        Found in framework/db/SqlTokenizer.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 ($column->size > 32) {
                                    $column->type = 'bigint';
                                } elseif ($column->size === 32) {
                                    $column->type = 'integer';
                                }
        Severity: Major
        Found in framework/db/mssql/Schema.php - About 45 mins to fix

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

              protected static function booleanInput($type, $name, $checked = false, $options = [])
              {
                  // 'checked' option has priority over $checked argument
                  if (!isset($options['checked'])) {
                      $options['checked'] = (bool) $checked;
          Severity: Minor
          Found in framework/helpers/BaseHtml.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 formatMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function formatMessage($message)
              {
                  list($text, $level, $category, $timestamp) = $message;
                  $level = Logger::getLevelName($level);
                  if (!is_string($text)) {
          Severity: Minor
          Found in framework/log/Target.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 parseExcludePattern has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function parseExcludePattern($pattern, $caseSensitive)
              {
                  if (!is_string($pattern)) {
                      throw new InvalidArgumentException('Exclude/include pattern must be a string.');
                  }
          Severity: Minor
          Found in framework/helpers/BaseFileHelper.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 loadDefaultValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function loadDefaultValues($skipIfSet = true)
              {
                  $columns = static::getTableSchema()->columns;
                  foreach ($this->attributes() as $name) {
                      if (isset($columns[$name])) {
          Severity: Minor
          Found in framework/db/ActiveRecord.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 rollBack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function rollBack()
              {
                  if (!$this->getIsActive()) {
                      // do nothing if transaction is not active: this could be the transaction is committed
                      // but the event handler to "commitTransaction" throw an exception
          Severity: Minor
          Found in framework/db/Transaction.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 createUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function createUrl($manager, $route, $params)
              {
                  $this->createStatus = WebUrlRule::CREATE_STATUS_SUCCESS;
                  foreach ($this->controller as $urlName => $controller) {
                      if (strpos($route, $controller) !== false) {
          Severity: Minor
          Found in framework/rest/UrlRule.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

          Severity
          Category
          Status
          Source
          Language