wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    protected function doPublishInternal( $fullCont, $dir, array $params ) {
        $status = $this->newStatus();
        if ( empty( $params['access'] ) ) {
            return $status; // nothing to do
        }
Severity: Minor
Found in includes/libs/filebackend/SwiftFileBackend.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 getFileListForWrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFileListForWrite( $params ) {
        $files = [];
        // Get the list of thumbnails from all backends to allow
        // deleting all of them. Otherwise, old thumbnails existing on
        // one backend only won't get updated in reupload (T331138).
Severity: Minor
Found in includes/libs/filebackend/FileBackendMultiWrite.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 getGhostFieldValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getGhostFieldValue( string $name, string ...$aliases ) {
        if ( isset( $this->$name ) ) {
            return $this->$name;
        }

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

    public function getHelpInfo( $name, array $settings, array $options ) {
        $info = parent::getHelpInfo( $name, $settings, $options );

        $min = '−∞';
        $max = '∞';
Severity: Minor
Found in includes/libs/ParamValidator/TypeDef/NumericDef.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 normalizePathsByType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function normalizePathsByType( array $pathsByType ) {
        $res = [];
        foreach ( $pathsByType as $type => $paths ) {
            foreach ( $paths as $path ) {
                if ( (string)$path === '' ) {
Severity: Minor
Found in includes/libs/lockmanager/LockManager.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 onError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '', $body = '' ) {
        if ( $this->isAuthFailureResponse( $code, $err ) ) {
            if ( $status instanceof StatusValue ) {
                $status->fatal( 'backend-fail-connect', $this->name );
            }
Severity: Minor
Found in includes/libs/filebackend/SwiftFileBackend.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 $config ) {
        $this->domain = $config['domain'] ?? 'global';
        if ( isset( $config['lockTTL'] ) ) {
            $this->lockTTL = max( self::MIN_LOCK_TTL, $config['lockTTL'] );
        } elseif ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
Severity: Minor
Found in includes/libs/lockmanager/LockManager.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 setConcurrencyFlags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function setConcurrencyFlags( array $opts ) {
        $opts['concurrency'] = 1; // off
        if ( $this->parallelize === 'implicit' ) {
            if ( $opts['parallelize'] ?? true ) {
                $opts['concurrency'] = $this->concurrency;
Severity: Minor
Found in includes/libs/filebackend/FileBackendStore.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 substOpBatchPaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function substOpBatchPaths( array $ops, FileBackendStore $backend ) {
        $newOps = []; // operations
        foreach ( $ops as $op ) {
            $newOp = $op; // operation
            foreach ( [ 'src', 'srcs', 'dst', 'dir' ] as $par ) {
Severity: Minor
Found in includes/libs/filebackend/FileBackendMultiWrite.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 getRequiredDependencies has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRequiredDependencies() {
        $deps = [];
        if ( isset( $this->contents['require'] ) ) {
            foreach ( $this->contents['require'] as $package => $version ) {
                // Examples of package dependencies that don't have a / in the name:
Severity: Minor
Found in includes/libs/composer/ComposerJson.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 deleteCacheFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function deleteCacheFiles() {
        foreach ( $this->fileHandles as $path => $handle ) {
            if ( $handle !== null ) {
                fclose( $handle );
            }
Severity: Minor
Found in includes/libs/uuid/GlobalIdGenerator.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 setStatsdNamespaces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setStatsdNamespaces( $statsdNamespaces ): void {
        if ( $this->statsdDataFactory === null ) {
            return;
        }
        $statsdNamespaces = is_array( $statsdNamespaces ) ? $statsdNamespaces : [ $statsdNamespaces ];
Severity: Minor
Found in includes/libs/Stats/Metrics/BaseMetric.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( $type, $value ) {
        if ( !in_array( $type, ParamType::cases() ) ) {
            throw new InvalidArgumentException( '$type must be one of the ParamType constants' );
        }
        if ( $type === ParamType::LIST ) {
Severity: Minor
Found in includes/libs/Message/ScalarParam.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 getMulti has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMulti( array $keys, $flags = 0 ) {
        $foundByKey = $this->doGetMulti( $keys, $flags );

        $res = [];
        foreach ( $keys as $key ) {
Severity: Minor
Found in includes/libs/objectcache/MediumSpecificBagOStuff.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 doPrecheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doPrecheck(
        FileStatePredicates $opPredicates,
        FileStatePredicates $batchPredicates
    ) {
        $status = StatusValue::newGood();
Severity: Minor
Found in includes/libs/filebackend/fileop/CopyFileOp.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function render(): array {
        $output = [];
        foreach ( $this->cache->getAllMetrics() as $metric ) {
            // Skip NullMetric instances.
            if ( get_class( $metric ) === NullMetric::class ) {
Severity: Minor
Found in includes/libs/Stats/Emitters/UDPEmitter.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( $tempDirectory, $shellCallback ) {
        if ( func_num_args() >= 3 && !is_callable( $shellCallback ) ) {
            trigger_error(
                __CLASS__ . ' with a BagOStuff instance was deprecated in MediaWiki 1.37.',
                E_USER_DEPRECATED
Severity: Minor
Found in includes/libs/uuid/GlobalIdGenerator.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 decodeBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function decodeBody( $body ) {
        $pieces = explode( '.', $body, 3 );
        if ( count( $pieces ) !== 3 || $pieces[0] !== $this->serializationType ) {
            return false;
        }
Severity: Minor
Found in includes/libs/objectcache/RESTBagOStuff.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 precheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function precheck( FileStatePredicates $predicates ) {
        if ( $this->state !== self::STATE_NEW ) {
            return StatusValue::newFatal( 'fileop-fail-state', self::STATE_NEW, $this->state );
        }
        $this->state = self::STATE_CHECKED;
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 encodeBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function encodeBody( $body ) {
        switch ( $this->serializationType ) {
            case 'JSON':
                $value = json_encode( $body );
                if ( $value === false ) {
Severity: Minor
Found in includes/libs/objectcache/RESTBagOStuff.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