wikimedia/mediawiki-core

View on GitHub
includes/objectcache/SqlBagOStuff.php

Summary

Maintainability
F
1 wk
Test Coverage

File SqlBagOStuff.php has 1141 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Object caching using a SQL database.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/objectcache/SqlBagOStuff.php - About 2 days to fix

    SqlBagOStuff has 56 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SqlBagOStuff extends MediumSpecificBagOStuff {
        /** @var callable|null Injected function which returns a LoadBalancer */
        protected $loadBalancerCallback;
        /** @var ILoadBalancer|null */
        protected $loadBalancer;
    Severity: Major
    Found in includes/objectcache/SqlBagOStuff.php - About 1 day to fix

      Function deleteObjectsExpiringBefore has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function deleteObjectsExpiringBefore(
              $timestamp,
              callable $progress = null,
              $limit = INF,
              string $tag = null
      Severity: Minor
      Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs 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 deleteServerObjectsExpiringBefore has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function deleteServerObjectsExpiringBefore(
              IDatabase $db,
              $timestamp,
              $limit,
              &$keysDeletedCount = 0,
      Severity: Major
      Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs to fix

        Function modifyTableSpecificBlobsForChangeTTL has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private function modifyTableSpecificBlobsForChangeTTL(
                IDatabase $db,
                string $ptable,
                float $mtime,
                array $argsByKey,
        Severity: Minor
        Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs 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 deleteServerObjectsExpiringBefore has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private function deleteServerObjectsExpiringBefore(
                IDatabase $db,
                $timestamp,
                $limit,
                &$keysDeletedCount = 0,
        Severity: Minor
        Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs 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 modifyTableSpecificBlobsForChangeTTL has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function modifyTableSpecificBlobsForChangeTTL(
                IDatabase $db,
                string $ptable,
                float $mtime,
                array $argsByKey,
        Severity: Major
        Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs to fix

          Method fetchBlobs has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function fetchBlobs( array $keys, bool $getCasToken = false ) {
                  /** @noinspection PhpUnusedLocalVariableInspection */
                  $silenceScope = $this->silenceTransactionProfiler();
          
                  // Initialize order-preserved per-key results; set values for live keys below
          Severity: Major
          Found in includes/objectcache/SqlBagOStuff.php - About 2 hrs to fix

            Function fetchBlobs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                private function fetchBlobs( array $keys, bool $getCasToken = false ) {
                    /** @noinspection PhpUnusedLocalVariableInspection */
                    $silenceScope = $this->silenceTransactionProfiler();
            
                    // Initialize order-preserved per-key results; set values for live keys below
            Severity: Minor
            Found in includes/objectcache/SqlBagOStuff.php - About 1 hr 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 modifyTableSpecificBlobsForCas has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function modifyTableSpecificBlobsForCas(
                    IDatabase $db,
                    string $ptable,
                    float $mtime,
                    array $argsByKey,
            Severity: Minor
            Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

              Method deleteObjectsExpiringBefore has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function deleteObjectsExpiringBefore(
                      $timestamp,
                      callable $progress = null,
                      $limit = INF,
                      string $tag = null
              Severity: Minor
              Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                Function modifyBlobs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function modifyBlobs(
                        callable $tableWriteCallback,
                        float $mtime,
                        array $argsByKey,
                        &$resByKey = []
                Severity: Minor
                Found in includes/objectcache/SqlBagOStuff.php - About 1 hr 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 modifyTableSpecificBlobsForIncrInit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function modifyTableSpecificBlobsForIncrInit(
                        IDatabase $db,
                        string $ptable,
                        float $mtime,
                        array $argsByKey,
                Severity: Minor
                Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                  Method modifyBlobs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function modifyBlobs(
                          callable $tableWriteCallback,
                          float $mtime,
                          array $argsByKey,
                          &$resByKey = []
                  Severity: Minor
                  Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                    Method modifyTableSpecificBlobsForAdd has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function modifyTableSpecificBlobsForAdd(
                            IDatabase $db,
                            string $ptable,
                            float $mtime,
                            array $argsByKey,
                    Severity: Minor
                    Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                      Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct( $params ) {
                              parent::__construct( $params );
                      
                              if ( isset( $params['servers'] ) || isset( $params['server'] ) ) {
                                  // Configuration uses a direct list of servers.
                      Severity: Minor
                      Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                        Method modifyTableSpecificBlobsForSet has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function modifyTableSpecificBlobsForSet(
                                IDatabase $db,
                                string $ptable,
                                float $mtime,
                                array $argsByKey,
                        Severity: Minor
                        Found in includes/objectcache/SqlBagOStuff.php - About 1 hr to fix

                          Function modifyTableSpecificBlobsForIncrInit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function modifyTableSpecificBlobsForIncrInit(
                                  IDatabase $db,
                                  string $ptable,
                                  float $mtime,
                                  array $argsByKey,
                          Severity: Minor
                          Found in includes/objectcache/SqlBagOStuff.php - About 1 hr 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 handleDBError has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function handleDBError( DBError $exception, $shardIndex ) {
                                  if ( !$this->useLB && $exception instanceof DBConnectionError ) {
                                      unset( $this->conns[$shardIndex] ); // bug T103435
                          
                                      $now = $this->getCurrentTime();
                          Severity: Minor
                          Found in includes/objectcache/SqlBagOStuff.php - About 1 hr 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 modifyTableSpecificBlobsForCas has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function modifyTableSpecificBlobsForCas(
                                  IDatabase $db,
                                  string $ptable,
                                  float $mtime,
                                  array $argsByKey,
                          Severity: Minor
                          Found in includes/objectcache/SqlBagOStuff.php - About 1 hr 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 __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function __construct( $params ) {
                                  parent::__construct( $params );
                          
                                  if ( isset( $params['servers'] ) || isset( $params['server'] ) ) {
                                      // Configuration uses a direct list of servers.
                          Severity: Minor
                          Found in includes/objectcache/SqlBagOStuff.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 buildIncrUpsertSet has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  IDatabase $db,
                                  int $step,
                                  int $init,
                                  int $expiry,
                                  string $mt,
                          Severity: Minor
                          Found in includes/objectcache/SqlBagOStuff.php - About 45 mins to fix

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

                                    IDatabase $db,
                                    $key,
                                    $serialValue,
                                    int $expiry,
                                    string $mt
                            Severity: Minor
                            Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                      IDatabase $db,
                                      string $ptable,
                                      float $mtime,
                                      array $argsByKey,
                                      array &$resByKey
                              Severity: Minor
                              Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                        IDatabase $db,
                                        string $ptable,
                                        float $mtime,
                                        array $argsByKey,
                                        array &$resByKey
                                Severity: Minor
                                Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                      protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
                                  Severity: Minor
                                  Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                        protected function doIncrWithInit( $key, $exptime, $step, $init, $flags ) {
                                    Severity: Minor
                                    Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                              IDatabase $db,
                                              string $ptable,
                                              float $mtime,
                                              array $argsByKey,
                                              array &$resByKey
                                      Severity: Minor
                                      Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                                IDatabase $db,
                                                $timestamp,
                                                $limit,
                                                &$keysDeletedCount = 0,
                                                array $progress = null
                                        Severity: Minor
                                        Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                                  IDatabase $db,
                                                  string $ptable,
                                                  float $mtime,
                                                  array $argsByKey,
                                                  array &$resByKey
                                          Severity: Minor
                                          Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                                    IDatabase $db,
                                                    string $ptable,
                                                    float $mtime,
                                                    array $argsByKey,
                                                    array &$resByKey
                                            Severity: Minor
                                            Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                                      IDatabase $db,
                                                      string $ptable,
                                                      float $mtime,
                                                      array $argsByKey,
                                                      array &$resByKey
                                              Severity: Minor
                                              Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

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

                                                        IDatabase $db,
                                                        string $ptable,
                                                        float $mtime,
                                                        array $argsByKey,
                                                        array &$resByKey
                                                Severity: Minor
                                                Found in includes/objectcache/SqlBagOStuff.php - About 35 mins to fix

                                                  Function doGetMulti has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      protected function doGetMulti( array $keys, $flags = 0 ) {
                                                          $result = [];
                                                          $valueSizeByKey = [];
                                                  
                                                          $dataByKey = $this->fetchBlobs( $keys );
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 35 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 getKeyLocation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private function getKeyLocation( $key ) {
                                                          if ( $this->useLB ) {
                                                              // LoadBalancer based configuration
                                                              $shardIndex = 0;
                                                          } else {
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 35 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 addCasTokenFields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private function addCasTokenFields( IDatabase $db, array $fields ) {
                                                          $type = $db->getType();
                                                  
                                                          if ( $type === 'mysql' ) {
                                                              $fields['castoken'] = $db->buildConcat( [
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 35 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 modifyTableSpecificBlobsForAdd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private function modifyTableSpecificBlobsForAdd(
                                                          IDatabase $db,
                                                          string $ptable,
                                                          float $mtime,
                                                          array $argsByKey,
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 25 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 buildMultiUpsertSetForOverwrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private function buildMultiUpsertSetForOverwrite( IDatabase $db, string $mt ) {
                                                          $expressionsByColumn = [
                                                              'value'   => $db->buildExcludedValue( 'value' ),
                                                              'exptime' => $db->buildExcludedValue( 'exptime' )
                                                          ];
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 25 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 createTables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function createTables() {
                                                          foreach ( $this->getShardServerIndexes() as $shardIndex ) {
                                                              $db = $this->getConnection( $shardIndex );
                                                              if ( in_array( $db->getType(), [ 'mysql', 'postgres' ], true ) ) {
                                                                  for ( $i = 0; $i < $this->numTableShards; $i++ ) {
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 25 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 unserialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      protected function unserialize( $value ) {
                                                          if ( $value === self::TOMB_SERIAL ) {
                                                              return false; // tombstone
                                                          }
                                                  
                                                  
                                                  Severity: Minor
                                                  Found in includes/objectcache/SqlBagOStuff.php - About 25 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

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status