wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public static function login( $username, $password, WebRequest $request ) {
        $enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()
            ->get( MainConfigNames::EnableBotPasswords );
        $passwordAttemptThrottle = MediaWikiServices::getInstance()->getMainConfig()
            ->get( MainConfigNames::PasswordAttemptThrottle );
Severity: Minor
Found in includes/user/BotPassword.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 getBaseRegex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBaseRegex( bool $capture = true, string $delimiter = '/' ): array {
        if ( $capture && $delimiter === '/' && $this->baseRegex !== null ) {
            return $this->baseRegex;
        }
        $regex = [ 0 => [], 1 => [] ];
Severity: Minor
Found in includes/parser/MagicWordArray.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 applyPrefix has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function applyPrefix( $name ) {
        $services = MediaWikiServices::getInstance();
        $userNameUtils = $services->getUserNameUtils();
        if ( $userNameUtils->getCanonical( $name, UserRigorOptions::RIGOR_USABLE ) === false ) {
            return $name;
Severity: Minor
Found in includes/user/ExternalUserNames.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 store has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function store( UserIdentity $user, array $updates ) {
        // In core, only users with local accounts may have preferences
        if ( !$user->getId() ) {
            return false;
        }
Severity: Minor
Found in includes/user/Options/LocalUserOptionsStore.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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $config ) {
        $this->enabled = $config['enabled'] ?? false;
        $this->known = $this->enabled || ( $config['known'] ?? false );

        // Configuration related to creating new temporary accounts for some actions
Severity: Minor
Found in includes/user/TempUser/RealTempUserConfig.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 getFile has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFile( $key, $noAuth = false ) {
        if ( !preg_match( self::KEY_FORMAT_REGEX, $key ) ) {
            throw new UploadStashBadPathException(
                wfMessage( 'uploadstash-bad-path-bad-format', $key )
            );
Severity: Minor
Found in includes/upload/UploadStash.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 findFiles has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function findFiles( array $items, $flags = 0 ) {
        $result = [];
        foreach ( $items as $item ) {
            if ( is_array( $item ) ) {
                $title = $item['title'];
Severity: Minor
Found in includes/filerepo/FileRepo.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 buildModuleMap has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildModuleMap(): array {
        $modules = [];
        $noPrefixFiles = [];
        $id = ''; // should not be used, make Phan happy

Severity: Minor
Found in includes/Rest/Router.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 getSearchResultsOrThrow has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSearchResultsOrThrow( $results ) {
        if ( $results ) {
            if ( $results instanceof StatusValue ) {
                $status = $results;
                if ( !$status->isOK() ) {
Severity: Minor
Found in includes/Rest/Handler/SearchHandler.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 getDbResults has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getDbResults( ExistingPageRecord $page, array $params, $relativeRevId, $ts, $tagIds ) {
        $dbr = $this->dbProvider->getReplicaDatabase();
        $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $dbr )
            ->joinComment()
            ->where( [ 'rev_page' => $page->getId() ] )
Severity: Minor
Found in includes/Rest/Handler/PageHistoryHandler.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 updateCategoryCounts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateCategoryCounts( array $insertedLinks, array $deletedLinks ) {
        if ( !$insertedLinks && !$deletedLinks ) {
            return;
        }

Severity: Minor
Found in includes/deferred/LinksUpdate/CategoryLinksTable.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 write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function write( array $record ): void {
        if ( $this->useLegacyFilter &&
            !LegacyLogger::shouldEmit(
                $record['channel'], $record['message'],
                $record['level'], $record
Severity: Minor
Found in includes/debug/logger/monolog/LegacyHandler.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 deprecatedMsg has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function deprecatedMsg( $msg, $version = false,
        $component = false, $callerOffset = 2
    ) {
        if ( $callerOffset === false ) {
            $callerFunc = '';
Severity: Minor
Found in includes/debug/MWDebug.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 getWikiText has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWikiText( StatusValue $status, array $options = [] ) {
        $shortContext = $options['shortContext'] ?? null;
        $longContext = $options['longContext'] ?? null;
        $lang = $options['lang'] ?? null;

Severity: Minor
Found in includes/Status/StatusFormatter.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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $config = [] ) {
        $config = array_merge( [
            // Default config values
            'precision' => 'day',
            'longDisplayFormat' => false,
Severity: Minor
Found in includes/widget/DateInputWidget.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 process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function process( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets ) {
        if ( $linesleft == 0 ) {
            return; // nothing to do
        }
        foreach ( $extracts as $index => $line ) {
Severity: Minor
Found in includes/search/SearchHighlighter.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 getTextSpawnedOnce has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTextSpawnedOnce( $address ) {
        if ( is_int( $address ) || intval( $address ) ) {
            $address = SqlBlobStore::makeAddressFromTextId( (int)$address );
        }

Severity: Minor
Found in maintenance/includes/TextPassDumper.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 notifyRCFeeds has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function notifyRCFeeds( array $feeds = null ) {
        $feeds ??=
            MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::RCFeeds );

        $performer = $this->getPerformerIdentity();
Severity: Minor
Found in includes/recentchanges/RecentChange.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 updateBatch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateBatch( IResultWrapper $res ) {
        if ( !$this->dryRun ) {
            $this->beginTransaction( $this->dbw, __METHOD__ );
        }
        foreach ( $res as $row ) {
Severity: Minor
Found in maintenance/updateCollation.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 execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

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

        $fromPattern = new Pattern( 'from', $this->getOption( 'from' ) );
        $toPattern = new Pattern( 'to', $this->getOption( 'to' ) );
Severity: Minor
Found in maintenance/renameUsersMatchingPattern.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