wikimedia/mediawiki-core

View on GitHub

Showing 11,779 of 11,779 total issues

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

    public function reformat( $preference, $text, $options = [] ) {
        $userFormatId = self::PREFERENCE_IDS[$preference] ?? self::NONE;
        foreach ( self::TARGET_FORMATS as $source => $_ ) {
            if ( isset( self::RULES[$userFormatId][$source] ) ) {
                # Specific rules
Severity: Minor
Found in includes/parser/DateFormatter.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 optionToString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function optionToString( $value ) {
        if ( $value === true ) {
            return '1';
        } elseif ( $value === false ) {
            return '0';
Severity: Minor
Found in includes/parser/ParserOptions.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 getDefaultOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDefaultOptions( ?UserIdentity $userIdentity = null ): array {
        $defaultOptions = $this->getGenericDefaultOptions();

        // If requested, process any conditional defaults
        if ( $userIdentity ) {
Severity: Minor
Found in includes/user/Options/DefaultOptionsLookup.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 loginHook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function loginHook( $user, $bp, User $performer, Status $status ) {
        $extraData = [
            'performer' => $performer
        ];
        if ( $user instanceof User ) {
Severity: Minor
Found in includes/user/BotPassword.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 isValid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function isValid( string $name ): bool {
        if ( $name === ''
            || $this->isIP( $name )
            || $this->isValidIPRange( $name )
            || $this->isLikeIPv4DashRange( $name )
Severity: Minor
Found in includes/user/UserNameUtils.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 getId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getId( $wikiId = self::LOCAL ): int {
        $this->assertWiki( $wikiId );
        if ( $this->mId === null && $this->mName !== null ) {
            $userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils();
            if ( $userNameUtils->isIP( $this->mName ) || ExternalUserNames::isExternal( $this->mName ) ) {
Severity: Minor
Found in includes/user/User.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 getActionText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getActionText() {
        if ( $this->canView( LogPage::DELETED_ACTION ) ) {
            $element = $this->getActionMessage();
            if ( $element instanceof Message ) {
                $element = $this->plaintext ? $element->text() : $element->escaped();
Severity: Minor
Found in includes/logging/LogFormatter.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 getUserGroupMemberships has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUserGroupMemberships(
        UserIdentity $user,
        int $queryFlags = IDBAccessObject::READ_NORMAL
    ): array {
        $user->assertWiki( $this->wikiId );
Severity: Minor
Found in includes/user/UserGroupManager.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 getExperienceLevel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getExperienceLevel() {
        $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
        $learnerEdits = $mainConfig->get( MainConfigNames::LearnerEdits );
        $experiencedUserEdits = $mainConfig->get( MainConfigNames::ExperiencedUserEdits );
        $learnerMemberSince = $mainConfig->get( MainConfigNames::LearnerMemberSince );
Severity: Minor
Found in includes/user/User.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 getMessageKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getMessageKey() {
        $type = $this->entry->getType();
        $subtype = $this->entry->getSubtype();
        $sitewide = $this->entry->getParameters()['sitewide'] ?? true;

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

    public function getToken( $forceCreation = true ) {
        $authenticationTokenVersion = MediaWikiServices::getInstance()
            ->getMainConfig()->get( MainConfigNames::AuthenticationTokenVersion );

        $this->load();
Severity: Minor
Found in includes/user/User.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 getTypeMenuDesc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTypeMenuDesc() {
        $typesByName = [];
        // Load the log names
        foreach ( LogPage::validTypes() as $type ) {
            $page = new LogPage( $type );
Severity: Minor
Found in includes/logging/LogEventsList.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 clearForPageView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function clearForPageView(
        UserIdentity $user,
        RevisionRecord $oldRev = null
    ) {
        // Abort if the hook says so. (Echo doesn't abort, it just queues its own update)
Severity: Minor
Found in includes/user/TalkPageNotificationManager.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 makePageLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
        if ( !$title instanceof Title ) {
            $msg = $this->msg( 'invalidtitle' )->text();
            if ( $this->plaintext ) {
                return $msg;
Severity: Minor
Found in includes/logging/LogFormatter.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 getBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBlock(
        $freshness = IDBAccessObject::READ_NORMAL,
        $disableIpBlockExemptChecking = false
    ): ?Block {
        if ( is_bool( $freshness ) ) {
Severity: Minor
Found in includes/user/User.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 getParameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getParameters() {
        if ( !isset( $this->params ) ) {
            $blob = $this->getRawParameters();
            AtEase::suppressWarnings();
            $params = LogEntryBase::extractParams( $blob );
Severity: Minor
Found in includes/logging/DatabaseLogEntry.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 makePageLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
        $userrightsInterwikiDelimiter = $this->context->getConfig()
            ->get( MainConfigNames::UserrightsInterwikiDelimiter );

        if ( !$this->plaintext ) {
Severity: Minor
Found in includes/logging/RightsLogFormatter.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 getActionLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getActionLinks() {
        $linkRenderer = $this->getLinkRenderer();
        $subtype = $this->entry->getSubtype();
        if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
            || $subtype === 'move_prot' // the move log entry has the right action link
Severity: Minor
Found in includes/logging/ProtectLogFormatter.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 getMessageKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getMessageKey() {
        $key = parent::getMessageKey();
        if ( in_array( $this->entry->getSubtype(), [ 'event', 'revision' ] ) ) {
            if ( count( $this->getMessageParameters() ) < 5 ) {
                // Messages: logentry-delete-event-legacy, logentry-delete-revision-legacy,
Severity: Minor
Found in includes/logging/DeleteLogFormatter.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 handleRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleRequest() {
        $thumbPath = $this->getConfig( MainConfigNames::ThumbPath );

        if ( $thumbPath ) {
            $relPath = $this->getRequestPathSuffix( $thumbPath );
Severity: Minor
Found in includes/filerepo/Thumbnail404EntryPoint.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