wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function ensureRevisionRowMatchesPage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function ensureRevisionRowMatchesPage( $row, PageIdentity $page, $context = [] ) {
        $revId = (int)( $row->rev_id ?? 0 );
        $revPageId = (int)( $row->rev_page ?? 0 ); // XXX: also check $row->page_id?
        $expectedPageId = $page->getId( $this->wikiId );
        // Avoid fatal error when the Title's ID changed, T246720
Severity: Minor
Found in includes/Revision/RevisionStore.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 doMoveInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doMoveInternal( array $params ) {
        $status = $this->newStatus();

        [ $srcCont, $srcRel ] = $this->resolveStoragePathReal( $params['src'] );
        if ( $srcRel === null ) {
Severity: Minor
Found in includes/libs/filebackend/SwiftFileBackend.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 doClean has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function doClean( array $params ) {
        /** @noinspection PhpUnusedLocalVariableInspection */
        $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
        $status = $this->newStatus();

Severity: Minor
Found in includes/libs/filebackend/FileBackendStore.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 insertRevisionRowOn has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function insertRevisionRowOn(
        IDatabase $dbw,
        RevisionRecord $rev,
        $parentId
    ) {
Severity: Minor
Found in includes/Revision/RevisionStore.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 parseRange has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parseRange( $range, $size ) {
        $m = [];
        if ( preg_match( '#^bytes=(\d*)-(\d*)$#', $range, $m ) ) {
            [ , $start, $end ] = $m;
            if ( $start === '' && $end === '' ) {
Severity: Minor
Found in includes/libs/filebackend/HTTPFileStreamer.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 freeLocksOnServer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function freeLocksOnServer( $lockSrv, array $pathsByType ) {
        $status = StatusValue::newGood();

        $pathList = array_merge( ...array_values( $pathsByType ) );

Severity: Minor
Found in includes/libs/lockmanager/RedisLockManager.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 attempt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function attempt( array $performOps, array $opts ) {
        $status = StatusValue::newGood();

        $n = count( $performOps );
        if ( $n > self::MAX_BATCH_SIZE ) {
Severity: Minor
Found in includes/libs/filebackend/FileOpBatch.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 doSingleUnlock has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doSingleUnlock( $path, $type ) {
        $status = StatusValue::newGood();

        if ( !isset( $this->locksHeld[$path] ) ) {
            $status->warning( 'lockmanager-notlocked', $path );
Severity: Minor
Found in includes/libs/lockmanager/FSLockManager.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 doSetMulti has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
        $ttl = $this->getExpirationAsTTL( $exptime );
        $op = $ttl ? 'setex' : 'set';

        $keys = array_keys( $data );
Severity: Minor
Found in includes/libs/objectcache/RedisBagOStuff.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 precheckDestExistence has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function precheckDestExistence(
        FileStatePredicates $opPredicates,
        $sourceSize,
        $sourceSha1
    ) {
Severity: Minor
Found in includes/libs/filebackend/fileop/FileOp.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 delimiterExplode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function delimiterExplode( $startDelim, $endDelim, $separator,
        $subject, $nested = false ) {
        $inputPos = 0;
        $lastPos = 0;
        $depth = 0;
Severity: Minor
Found in includes/libs/StringUtils.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 doChangeTTLMulti has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function doChangeTTLMulti( array $keys, $exptime, $flags = 0 ) {
        $relative = $this->isRelativeExpiration( $exptime );
        $op = ( $exptime == self::TTL_INDEFINITE )
            ? 'persist'
            : ( $relative ? 'expire' : 'expireAt' );
Severity: Minor
Found in includes/libs/objectcache/RedisBagOStuff.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 get has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function get( $key, &$casToken = null ) {
        $getToken = ( func_num_args() >= 2 );

        $this->_last_cmd_status = self::ERR_NONE;

Severity: Minor
Found in includes/libs/objectcache/utils/MemcachedClient.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 handleError has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleError( $msg, $rcode, $rerr, $rhdrs, $rbody, $context = [] ) {
        $message = "$msg : ({code}) {error}";
        $context = [
            'code' => $rcode,
            'error' => $rerr
Severity: Minor
Found in includes/libs/objectcache/RESTBagOStuff.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 parseMimeTypes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseMimeTypes( string $rawMimeTypes ): void {
        $rawMimeTypes = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $rawMimeTypes );
        $rawMimeTypes = str_replace( "\t", " ", $rawMimeTypes );

        $lines = explode( "\n", $rawMimeTypes );
Severity: Minor
Found in includes/libs/mime/MimeAnalyzer.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 __toString has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function __toString() {
        $status = $this->isOK() ? "OK" : "Error";
        if ( count( $this->errors ) ) {
            $errorcount = "collected " . ( count( $this->errors ) ) . " message(s) on the way";
        } else {
Severity: Minor
Found in includes/libs/StatusValue.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 improveTypeFromExtension has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function improveTypeFromExtension( string $mime, string $ext ): ?string {
        if ( $mime === 'unknown/unknown' ) {
            if ( $this->isRecognizableExtension( $ext ) ) {
                $this->logger->info( __METHOD__ . ': refusing to guess mime type for .' .
                    "$ext file, we should have recognized it" );
Severity: Minor
Found in includes/libs/mime/MimeAnalyzer.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 doCreateInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doCreateInternal( array $params ) {
        $status = $this->newStatus();

        $fsDstPath = $this->resolveToFSPath( $params['dst'] );
        if ( $fsDstPath === null ) {
Severity: Minor
Found in includes/libs/filebackend/FSFileBackend.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 makeInsertLists has a Cognitive Complexity of 13 (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/PostgresPlatform.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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( string $field, string $op, $value ) {
        if ( !in_array( $op, IExpression::ACCEPTABLE_OPERATORS ) ) {
            throw new InvalidArgumentException( "Operator $op is not supported" );
        }
        if (
Severity: Minor
Found in includes/libs/rdbms/expression/Expression.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

Severity
Category
Status
Source
Language