yiisoft/yii2

View on GitHub

Showing 787 of 2,467 total issues

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

    public function getPreferredLanguage(array $languages = [])
    {
        if (empty($languages)) {
            return Yii::$app->language;
        }
Severity: Minor
Found in framework/web/Request.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 setCookieParamsInternal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function setCookieParamsInternal()
    {
        $data = $this->getCookieParams();
        if (isset($data['lifetime'], $data['path'], $data['domain'], $data['secure'], $data['httponly'])) {
            if (PHP_VERSION_ID >= 70300) {
Severity: Minor
Found in framework/web/Session.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 updateFlashCounters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function updateFlashCounters()
    {
        $counters = $this->get($this->flashParam, []);
        if (is_array($counters)) {
            foreach ($counters as $key => $count) {
Severity: Minor
Found in framework/web/Session.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 updateDynamicContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function updateDynamicContent($content, $placeholders, $isRestoredFromCache = false)
    {
        if (empty($placeholders) || !is_array($placeholders)) {
            return $content;
        }
Severity: Minor
Found in framework/base/DynamicContentAwareTrait.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 loginRequired has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
    {
        $request = Yii::$app->getRequest();
        $canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
        if (
Severity: Minor
Found in framework/web/User.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 getAllFlashes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllFlashes($delete = false)
    {
        $counters = $this->get($this->flashParam, []);
        $flashes = [];
        foreach (array_keys($counters) as $key) {
Severity: Minor
Found in framework/web/Session.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct($url, $statusCode = 302, $scheme = false, $message = null, $code = 0, $previous = null)
Severity: Minor
Found in framework/web/UrlNormalizerRedirectException.php - About 45 mins to fix

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

        public static function on($class, $name, $handler, $data = null, $append = true)
        {
            $class = ltrim($class, '\\');
    
            if (strpos($class, '*') !== false || strpos($name, '*') !== false) {
    Severity: Minor
    Found in framework/base/Event.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 renderCallStackItem has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function renderCallStackItem($file, $line, $class, $method, $args, $index)
    Severity: Minor
    Found in framework/web/ErrorHandler.php - About 45 mins to fix

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

          private function normalizeComplexFilter(array $filter)
          {
              $result = [];
              foreach ($filter as $key => $value) {
                  if (isset($this->filterControls[$key])) {
      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

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

          public function save($filePath, $messages)
          {
              if (false === ($fileHandle = @fopen($filePath, 'wb'))) {
                  throw new Exception('Unable to write file "' . $filePath . '".');
              }
      Severity: Minor
      Found in framework/i18n/GettextMoFile.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 formatNumber has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          protected function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions)
      Severity: Minor
      Found in framework/i18n/Formatter.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

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

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

              protected function validateImage($image)
              {
                  if (false === ($imageInfo = getimagesize($image->tempName))) {
                      return [$this->notImage, ['file' => $image->name]];
                  }
          Severity: Minor
          Found in framework/validators/ImageValidator.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 init has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function init()
              {
                  parent::init();
                  if ($this->message === null) {
                      switch ($this->operator) {
          Severity: Minor
          Found in framework/validators/CompareValidator.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 prepareRanges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function prepareRanges($ranges)
              {
                  $result = [];
                  foreach ($ranges as $string) {
                      list($isRangeNegated, $range) = $this->parseNegatedRange($string);
          Severity: Minor
          Found in framework/validators/IpValidator.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 getRootAlias has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getRootAlias($alias)
              {
                  $pos = strpos($alias, '/');
                  $root = $pos === false ? $alias : substr($alias, 0, $pos);
          
          
          Severity: Minor
          Found in framework/BaseYii.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 validateAttribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function validateAttribute($model, $attribute)
              {
                  $files = $this->filterFiles(is_array($model->$attribute) ? $model->$attribute : [$model->$attribute]);
                  $filesCount = count($files);
                  if ($filesCount === 0 && $this->minFiles > 0) {
          Severity: Minor
          Found in framework/validators/FileValidator.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 getOrders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getOrders($recalculate = false)
              {
                  $attributeOrders = $this->getAttributeOrders($recalculate);
                  $orders = [];
                  foreach ($attributeOrders as $attribute => $direction) {
          Severity: Minor
          Found in framework/data/Sort.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 formatUnit has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function formatUnit($unitType, $unitFormat, $value, $decimals, $options, $textOptions)
          Severity: Minor
          Found in framework/i18n/Formatter.php - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language