wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function beginAuthentication has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function beginAuthentication( array $reqs, $returnToUrl ) {
        $session = $this->request->getSession();
        if ( !$session->canSetUser() ) {
            // Caller should have called canAuthenticateNow()
            $session->remove( self::AUTHN_STATE );
Severity: Minor
Found in includes/auth/AuthManager.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 findMostProgress has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private static function findMostProgress( $M, $N, $limit, $V ) {
        $delta = $N - $M;

        if ( ( $M & 1 ) == ( $limit & 1 ) ) {
            $forward_start_diag = max( -$M, -$limit );
Severity: Minor
Found in includes/libs/Diff/DiffEngine.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 serializeOne has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function serializeOne( &$value ) {
        if ( $value instanceof JsonSerializable ) {
            $value = $value->jsonSerialize();
            if ( !is_array( $value ) ) {
                // Although JsonSerializable doesn't /require/ the result to be
Severity: Minor
Found in includes/json/JsonCodec.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 doOperationsInternal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function doOperationsInternal( array $ops, array $opts ) {
        $status = $this->newStatus();

        $fname = __METHOD__;
        $mbe = $this->backends[$this->masterIndex]; // convenience
Severity: Minor
Found in includes/libs/filebackend/FileBackendMultiWrite.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 internalGetCount has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function internalGetCount(
        $metricName,
        EntityKey $entity,
        MetricSpec $metricSpec,
        SequenceSpec $seqSpec,
Severity: Minor
Found in includes/libs/WRStats/WRStatsReader.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 doIncrWithInit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doIncrWithInit( $key, $exptime, $step, $init, $flags ) {
        // Use apcu 5.1.12 $ttl argument if apcu_inc() will initialize to $init:
        // https://www.php.net/manual/en/function.apcu-inc.php
        if ( $step === $init ) {
            /** @noinspection PhpMethodParametersCountMismatchInspection */
Severity: Minor
Found in includes/libs/objectcache/APCUBagOStuff.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 doGetMulti has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doGetMulti( array $keys, $flags = 0 ) {
        $blobsFound = [];

        [ $keysByServer, $connByServer ] = $this->getConnectionsForKeys( $keys );
        foreach ( $keysByServer as $server => $batchKeys ) {
Severity: Minor
Found in includes/libs/objectcache/RedisBagOStuff.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 parseAccept has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseAccept( $accept ): array {
        $accepts = explode( ',', $accept );  // FIXME: Allow commas in quotes
        $ret = [];

        foreach ( $accepts as $i => $a ) {
Severity: Minor
Found in includes/libs/http/HttpAcceptParser.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 open has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
        $this->close( __METHOD__ );

        // Note that for SQLite, $server, $user, and $pass are ignored

Severity: Minor
Found in includes/libs/rdbms/database/DatabaseSqlite.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 getRawText has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRawText() {
        $text = false;
        $title = $this->getTitle();
        $request = $this->getRequest();

Severity: Minor
Found in includes/actions/RawAction.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 getRemoteUrl has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getRemoteUrl() {
        if ( !isset( $this->cache['remoteURL'] ) ) {
            $config = "{$this->basedir}/config";
            $url = false;
            if ( is_readable( $config ) ) {
Severity: Minor
Found in includes/utils/GitInfo.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 convertNewsCode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function convertNewsCode( $val ) {
        if ( !preg_match( '/^\d{8}$/D', $val ) ) {
            // Not a valid news code.
            return $val;
        }
Severity: Minor
Found in includes/media/FormatMetadata.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 compress has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function compress() {
        if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
            throw new RuntimeException( "Need xdiff support to write DiffHistoryBlob\n" );
        }
        if ( isset( $this->mDiffs ) ) {
Severity: Minor
Found in includes/historyblob/DiffHistoryBlob.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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->useTransactionalTimeLimit();
        $params = $this->extractRequestParams();

        $this->requireMaxOneParameter( $params, 'namespace', 'rootpage' );
Severity: Minor
Found in includes/api/ApiImport.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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->useTransactionalTimeLimit();

        $params = $this->extractRequestParams();
        $user = $this->getUser();
Severity: Minor
Found in includes/api/ApiRevisionDelete.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 validateValue has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private static function validateValue( $value ) {
        if ( is_object( $value ) ) {
            // Note we use is_callable() here instead of instanceof because
            // ApiSerializable is an informal protocol (see docs there for details).
            if ( is_callable( [ $value, 'serializeForApiResult' ] ) ) {
Severity: Minor
Found in includes/api/ApiResult.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 outputGeneralPageInfo has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function outputGeneralPageInfo() {
        $pageSet = $this->getPageSet();
        $result = $this->getResult();

        // We can't really handle max-result-size failure here, but we need to
Severity: Minor
Found in includes/api/ApiQuery.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 getExternalLibraries has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getExternalLibraries( array $credits ) {
        $paths = [
            MW_INSTALL_PATH . '/vendor/composer/installed.json'
        ];

Severity: Minor
Found in includes/specials/SpecialVersion.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 isValidISBN has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isValidISBN( $isbn ) {
        $isbn = self::cleanIsbn( $isbn );
        $sum = 0;
        if ( strlen( $isbn ) == 13 ) {
            for ( $i = 0; $i < 12; $i++ ) {
Severity: Minor
Found in includes/specials/SpecialBookSources.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 breakSyntax has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function breakSyntax( $openingCount = false ) {
        if ( $this->open == "\n" ) {
            $accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out );
        } else {
            if ( $openingCount === false ) {
Severity: Minor
Found in includes/parser/PPDStackElement_Hash.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

Severity
Category
Status
Source
Language