wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    public function acquireLinkTargetId( LinkTarget $linkTarget, IDatabase $dbw ): int {
        // allow cache to be used, because if it is in the cache, it already has a linktarget id
        $existingLinktargetId = $this->getLinkTargetIdFromCache( $linkTarget );
        if ( $existingLinktargetId ) {
            return $existingLinktargetId;
Severity: Minor
Found in includes/linker/LinkTargetStore.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 formatPermissionsErrorMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatPermissionsErrorMessage( array $errors, $action = null ) {
        if ( $action == null ) {
            $text = $this->msg( 'permissionserrorstext', count( $errors ) )->plain() . "\n\n";
        } else {
            $action_desc = $this->msg( "action-$action" )->plain();
Severity: Minor
Found in includes/Output/OutputPage.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 consumeNoFork has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function consumeNoFork() {
        while ( !feof( $this->input ) ) {
            $data = fgets( $this->input );
            if ( substr( $data, -1 ) === "\n" ) {
                // Strip any final new line used to delimit lines of input.
Severity: Minor
Found in includes/Maintenance/OrderedStreamingForkController.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 doBatchPush has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doBatchPush( array $jobs, $flags ) {
        // Local ring variable that may be changed to point to a new ring on failure
        $partitionRing = $this->partitionRing;
        // Try to insert the jobs and update $partitionsTry on any failures.
        // Retry to insert any remaining jobs again, ignoring the bad partitions.
Severity: Minor
Found in includes/jobqueue/JobQueueFederated.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 getDeduplicationInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDeduplicationInfo() {
        $info = [
            'type' => $this->getType(),
            'params' => $this->getParams()
        ];
Severity: Minor
Found in includes/jobqueue/JobSpecification.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 formatRaw has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function formatRaw(
        $num, $raw, $language, MagicWordFactory $magicWordFactory = null
    ) {
        if ( $raw !== null && $raw !== '' ) {
            if ( !$magicWordFactory ) {
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 checkMemoryOK has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkMemoryOK() {
        static $maxBytes = null;
        if ( $maxBytes === null ) {
            $m = [];
            if ( preg_match( '!^(\d+)(k|m|g|)$!i', ini_get( 'memory_limit' ), $m ) ) {
Severity: Minor
Found in includes/jobqueue/JobRunner.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 decodeTagAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function decodeTagAttributes( string $text ): array {
        if ( trim( $text ) == '' ) {
            return [];
        }

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

    public static function defaultsort( $parser, $text, $uarg = '' ) {
        static $magicWords = null;
        if ( $magicWords === null ) {
            $magicWords = $parser->getMagicWordFactory()->newArray(
                [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
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 forkWorkers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function forkWorkers( $numProcs ) {
        $this->prepareEnvironment();

        // Create the child processes
        for ( $i = 0; $i < $numProcs; $i++ ) {
Severity: Minor
Found in includes/Maintenance/ForkController.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 parseUncacheable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseUncacheable(
        PageIdentity $page,
        ParserOptions $parserOpts,
        $revision,
        bool $lenientRevHandling = false
Severity: Minor
Found in includes/parser/Parsoid/ParsoidOutputAccess.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 genParserOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function genParserOutput(
        PageConfig $pageConfig, ParserOptions $options
    ): ParserOutput {
        $parserOutput = new ParserOutput();

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

    public function getMetadata(
        PageRecord $page,
        int $staleConstraint = self::USE_ANYTHING
    ): ?ParserCacheMetadata {
        $page->assertWiki( PageRecord::LOCAL );
Severity: Minor
Found in includes/parser/ParserCache.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 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 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 detectAndEncodeBinary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function detectAndEncodeBinary( array $properties ) {
        foreach ( $properties as $key => $value ) {
            if ( is_string( $value ) ) {
                if ( !mb_detect_encoding( $value, 'UTF-8', true ) ) {
                    $properties[$key] = [
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 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

Severity
Category
Status
Source
Language