wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function filterViaNext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function filterViaNext() {
        while ( $this->iter->valid() ) {
            if ( $this->iter->current()->isDot() || !$this->iter->current()->isDir() ) {
                $this->iter->next(); // skip non-directories and dot files
            } else {
Severity: Minor
Found in includes/libs/filebackend/fileiteration/FSFileBackendDirList.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 encodeArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function encodeArray( array $array, $indent = 0 ) {
        $code = "[\n";
        $tabs = str_repeat( "\t", $indent );
        if ( array_is_list( $array ) ) {
            foreach ( $array as $item ) {
Severity: Minor
Found in includes/libs/StaticArrayWriter.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 sampleData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function sampleData( $data ) {
        $newData = [];
        $mt_rand_max = mt_getrandmax();
        foreach ( $data as $item ) {
            $samplingRate = $item->getSampleRate();
Severity: Minor
Found in includes/libs/Stats/SamplingStatsdClient.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 makeMultiKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function makeMultiKeys( array $ids, $keyCallback ) {
        $idByKey = [];
        foreach ( $ids as $id ) {
            // Discourage triggering of automatic makeKey() hashing in some backends
            if ( strlen( $id ) > 64 ) {
Severity: Minor
Found in includes/libs/objectcache/WANObjectCache.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 attempt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function attempt() {
        if ( $this->state !== self::STATE_CHECKED ) {
            return StatusValue::newFatal( 'fileop-fail-state', self::STATE_CHECKED, $this->state );
        } elseif ( $this->failed ) { // failed precheck
            return StatusValue::newFatal( 'fileop-fail-attempt-precheck' );
Severity: Minor
Found in includes/libs/filebackend/fileop/FileOp.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $options ) {
        if ( isset( $options['caBundlePath'] ) ) {
            $this->caBundlePath = $options['caBundlePath'];
            if ( !file_exists( $this->caBundlePath ) ) {
                throw new InvalidArgumentException( "Cannot find CA bundle: " . $this->caBundlePath );
Severity: Minor
Found in includes/libs/http/MultiHttpClient.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 getWithSetCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function getWithSetCallback(
        $key, $ttl, $callback, array $opts = [], array $cbParams = []
    ) {
        $version = $opts['version'] ?? null;
        $pcTTL = $opts['pcTTL'] ?? self::TTL_UNCACHEABLE;
Severity: Minor
Found in includes/libs/objectcache/WANObjectCache.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 doGet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doGet( $key, $flags = 0, &$casToken = null ) {
        $getToken = ( $casToken === self::PASS_BY_REF );
        $casToken = null;

        $conn = $this->getConnection( $key );
Severity: Minor
Found in includes/libs/objectcache/RedisBagOStuff.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 updateSqlText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateSqlText( $table, $set, $conds, $options ) {
        $isCondValid = ( is_string( $conds ) || is_array( $conds ) ) && $conds;
        if ( !$isCondValid ) {
            throw new DBLanguageError( __METHOD__ . ' called with empty conditions' );
        }
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 getFirstSupportedValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFirstSupportedValue( array $preferences, $default = null ) {
        foreach ( $preferences as $value ) {
            foreach ( $this->supportedValues as $supported ) {
                if ( $this->valueMatches( $value, $supported ) ) {
                    return $supported;
Severity: Minor
Found in includes/libs/http/HttpAcceptNegotiator.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 checkResult has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function checkResult( $key, $result ) {
        static $statusByCode = [
            Memcached::RES_HOST_LOOKUP_FAILURE => self::ERR_UNREACHABLE,
            Memcached::RES_SERVER_MARKED_DEAD => self::ERR_UNREACHABLE,
            Memcached::RES_SERVER_TEMPORARILY_DISABLED => self::ERR_UNREACHABLE,
Severity: Minor
Found in includes/libs/objectcache/MemcachedPeclBagOStuff.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 _fwrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    function _fwrite( $sock, $buf ) {
        $bytesWritten = 0;
        $bufSize = strlen( $buf );
        while ( $bytesWritten < $bufSize ) {
            $result = fwrite( $sock, $buf );
Severity: Minor
Found in includes/libs/objectcache/utils/MemcachedClient.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 doAttempt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doAttempt() {
        if ( $this->overwriteSameCase ) {
            if ( $this->params['src'] === $this->params['dst'] ) {
                // Do nothing to the destination (which is also the source)
                $status = StatusValue::newGood();
Severity: Minor
Found in includes/libs/filebackend/fileop/MoveFileOp.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 addQuotes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function addQuotes( $s ) {
        if ( $s instanceof RawSQLValue ) {
            return $s->toSql();
        }
        if ( $s instanceof Blob ) {
Severity: Minor
Found in includes/libs/rdbms/database/DatabaseSqlite.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 selectRowCount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function selectRowCount(
        $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
    ): int {
        $conds = $this->platform->normalizeConditions( $conds, $fname );
        $column = $this->platform->extractSingleFieldFromList( $var );
Severity: Minor
Found in includes/libs/rdbms/database/Database.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 commitPrimaryChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function commitPrimaryChanges( $fname = __METHOD__, int $maxWriteDuration = 0 ) {
        $this->assertTransactionRoundStage( self::ROUND_CURSORY );
        /** @noinspection PhpUnusedLocalVariableInspection */
        $scope = ScopedCallback::newScopedIgnoreUserAbort();

Severity: Minor
Found in includes/libs/rdbms/lbfactory/LBFactory.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 validateFromInput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function validateFromInput( $xml, $isFile ) {
        $reader = new XMLReader();
        if ( $isFile ) {
            $s = $reader->open( $xml, null, LIBXML_NOERROR | LIBXML_NOWARNING );
        } else {
Severity: Minor
Found in includes/libs/mime/XmlTypeCheck.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 assertBuildSubstringParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function assertBuildSubstringParams( $startPosition, $length ) {
        if ( $startPosition === 0 ) {
            // The DBMSs we support use 1-based indexing here.
            throw new InvalidArgumentException( 'Use 1 as $startPosition for the beginning of the string' );
        }
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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 __destruct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __destruct() {
        foreach ( $this->connections as &$serverConnections ) {
            foreach ( $serverConnections as &$connection ) {
                try {
                    /** @var Redis $conn */
Severity: Minor
Found in includes/libs/redis/RedisConnectionPool.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 makeInsertLists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeInsertLists( array $rows, $aliasPrefix = '', array $typeByColumn = [] ) {
        $firstRow = $rows[0];
        if ( !is_array( $firstRow ) || !$firstRow ) {
            throw new DBLanguageError( 'Got an empty row list or empty row' );
        }
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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

Severity
Category
Status
Source
Language