wikimedia/mediawiki-core

View on GitHub

Showing 10,790 of 10,790 total issues

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

    public function getCurrentRevisionCallback() {
        wfDeprecated( __METHOD__, '1.35' );
        $revCb = $this->getOption( 'currentRevisionCallback' );

        // As a temporary measure, while both currentRevisionCallback and
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 isSafeToCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function isSafeToCache() {
        $defaults = self::getCanonicalOverrides() + self::getDefaults();
        foreach ( $this->options as $option => $value ) {
            if ( empty( self::$inCacheKey[$option] ) ) {
                $v = $this->optionToString( $value );
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 normalizeLinkUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function normalizeLinkUrl( $url ) {
        # Test for RFC 3986 IPv6 syntax
        $scheme = '[a-z][a-z0-9+.-]*:';
        $userinfo = '(?:[a-z0-9\-._~!$&\'()*+,;=:]|%[0-9a-f]{2})*';
        $ipv6Host = '\\[((?:[0-9a-f:]|%3[0-A]|%[46][1-6])+)\\]';
Severity: Minor
Found in includes/parser/Parser.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 addLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function addLink( Title $title, $id = null ) {
        if ( $title->isExternal() ) {
            // Don't record interwikis in pagelinks
            $this->addInterwikiLink( $title );
            return;
Severity: Minor
Found in includes/parser/ParserOutput.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 __toString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __toString() {
        $inner = '';
        $attribs = '';
        for ( $node = $this->getFirstChild(); $node; $node = $node->getNextSibling() ) {
            if ( $node instanceof PPNode_Hash_Attr ) {
Severity: Minor
Found in includes/parser/PPNode_Hash_Tree.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 mergeInternalMetaDataFrom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function mergeInternalMetaDataFrom( ParserOutput $source ) {
        $this->mOutputHooks = self::mergeList( $this->mOutputHooks, $source->getOutputHooks() );
        $this->mWarnings = self::mergeMap( $this->mWarnings, $source->mWarnings ); // don't use getter
        $this->mTimestamp = $this->useMaxValue( $this->mTimestamp, $source->getTimestamp() );

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

    public static function gender( $parser, $username, ...$forms ) {
        // Some shortcuts to avoid loading user data unnecessarily
        if ( count( $forms ) === 0 ) {
            return '';
        } elseif ( count( $forms ) === 1 ) {
Severity: Minor
Found in includes/parser/CoreParserFunctions.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 internalParse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function internalParse( $text, $isMain = true, $frame = false ) {
        $origText = $text;

        # Hook to suspend the parser in this state
        if ( !$this->hookRunner->onParserBeforeInternalParse( $this, $text, $this->mStripState ) ) {
Severity: Minor
Found in includes/parser/Parser.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 getExternalLinkAttribs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getExternalLinkAttribs( $url ) {
        $attribs = [];
        $rel = self::getExternalLinkRel( $url, $this->getTitle() );

        $target = $this->mOptions->getExternalLinkTarget();
Severity: Minor
Found in includes/parser/Parser.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function save( $operation, Password $password = null ) {
        $conds = [
            'bp_user' => $this->centralId,
            'bp_app_id' => $this->appId,
        ];
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 getDefaultOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDefaultOptions(): array {
        if ( $this->defaultOptions !== null ) {
            return $this->defaultOptions;
        }

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

    protected function getStartBody() {
        # Do a link batch query
        if ( $this->getNumRows() > 0 ) {
            $lb = new LinkBatch;
            foreach ( $this->mResult as $row ) {
Severity: Minor
Found in includes/logging/LogPager.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 ) {
        global $wgUserrightsInterwikiDelimiter;

        if ( !$this->plaintext ) {
            $text = MediaWikiServices::getInstance()->getContentLanguage()->
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 createFromRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createFromRequest( &$request, $type = null ) {
        $type = $type ?: $request->getVal( 'wpSourceType', 'File' );

        if ( !$type ) {
            return null;
Severity: Minor
Found in includes/upload/UploadBase.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 verifyTitlePermissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function verifyTitlePermissions( $user ) {
        /**
         * If the image is protected, non-sysop users won't be able
         * to modify it by uploading a new revision.
         */
Severity: Minor
Found in includes/upload/UploadBase.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, Status $status ) {
        $extraData = [];
        if ( $user instanceof User ) {
            $name = $user->getName();
            if ( $bp ) {
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 getUserImplicitGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUserImplicitGroups(
        UserIdentity $user,
        int $queryFlags = self::READ_NORMAL,
        bool $recache = false
    )  : array {
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 __set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __set( $name, $value ) {
        // A shortcut for $mRights deprecation phase, only known legitimate use was for
        // testing purposes, other uses seem bad in principle
        if ( $name === 'mRights' ) {
            MediaWikiServices::getInstance()->getPermissionManager()->overrideUserRightsForTesting(
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

Severity
Category
Status
Source
Language