wikimedia/mediawiki-core

View on GitHub

Showing 11,779 of 11,779 total issues

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

    public static function logException(
        Throwable $e,
        $catcher = self::CAUGHT_BY_OTHER,
        $extraData = []
    ) {
Severity: Minor
Found in includes/exception/MWExceptionHandler.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function run() {
        $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get(
            MainConfigNames::UpdateRowsPerQuery );
        $userId = $this->params['userId'];
        $maxWatchlistId = $this->params['maxWatchlistId'];
Severity: Minor
Found in includes/jobqueue/jobs/ClearUserWatchlistJob.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 purgeExpiredRows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function purgeExpiredRows() {
        $services = MediaWikiServices::getInstance();
        $rcMaxAge = $services->getMainConfig()->get(
            MainConfigNames::RCMaxAge );
        $updateRowsPerQuery = $services->getMainConfig()->get(
Severity: Minor
Found in includes/jobqueue/jobs/RecentChangesUpdateJob.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 prepareErrorPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function prepareErrorPage( $pageTitle = null, $htmlTitle = false ) {
        if ( $pageTitle !== null || $htmlTitle !== false ) {
            wfDeprecated( __METHOD__ . ' with explicit arguments', '1.41' );
            if ( $pageTitle !== null ) {
                $this->setPageTitle( $pageTitle );
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 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 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 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 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 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 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 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 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 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 __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 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 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 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

Severity
Category
Status
Source
Language