wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function guessTitle has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function guessTitle() {
        if ( $this->guessedTitle !== false ) {
            return $this->guessedTitle;
        }

Severity: Minor
Found in includes/api/ApiComparePages.php - About 2 hrs 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 loadRequest has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadRequest( $par ) {
        $request = $this->getRequest();
        $user = $this->getUser();

        $this->mAction = $request->getRawVal( 'action' );
Severity: Minor
Found in includes/specials/SpecialUndelete.php - About 2 hrs 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 showUploadStatus has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function showUploadStatus( $user ) {
        // first, let's fetch the status from the main stash
        $progress = UploadBase::getSessionStatus( $user, $this->mCacheKey );
        if ( !$progress ) {
            $progress = [ 'status' => Status::newFatal( 'invalid-cache-key' ) ];
Severity: Minor
Found in includes/specials/SpecialUpload.php - About 2 hrs 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 tryJobInsertions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryJobInsertions( array $jobs, HashRing &$partitionRing, $flags ) {
        $jobsLeft = [];

        // Because jobs are spread across partitions, per-job de-duplication needs
        // to use a consistent hash to avoid allowing duplicate jobs per partition.
Severity: Minor
Found in includes/jobqueue/JobQueueFederated.php - About 2 hrs 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 newChild has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function newChild( $args = false, $title = false, $indexOffset = 0 ) {
        $namedArgs = [];
        $numberedArgs = [];
        if ( $title === false ) {
            $title = $this->title;
Severity: Minor
Found in includes/parser/PPFrame_Hash.php - About 2 hrs 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 findFile has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function findFile( $title, $options = [] ) {
        if ( !is_array( $options ) ) {
            // MW 1.15 compat
            $options = [ 'time' => $options ];
        }
Severity: Minor
Found in includes/filerepo/RepoGroup.php - About 2 hrs 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 upload has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function upload( $src, $comment, $pageText, $flags = 0, $props = false,
        $timestamp = false, Authority $uploader = null, $tags = [],
        $createNullRevision = true, $revert = false
    ) {
        if ( $this->getRepo()->getReadOnlyReason() !== false ) {
Severity: Minor
Found in includes/filerepo/file/LocalFile.php - About 2 hrs 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 getHashes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getHashes( StatusValue $status ): array {
        $hashes = [];
        [ $oldRels, $deleteCurrent ] = $this->getOldRels();

        if ( $deleteCurrent ) {
Severity: Minor
Found in includes/filerepo/file/LocalFileDeleteBatch.php - About 2 hrs 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 getRequestAttributes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function &getRequestAttributes(): array {
        if ( $this->requestAttributes ) {
            return $this->requestAttributes;
        }

Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.php - About 2 hrs 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 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function run( $title ) {
        $params = $this->getValidatedParams();
        if ( $params['older_than'] !== null && $params['newer_than'] !== null ) {
            throw new LocalizedHttpException(
                new MessageValue( 'rest-pagehistory-incompatible-params' ), 400 );
Severity: Minor
Found in includes/Rest/Handler/PageHistoryHandler.php - About 2 hrs 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 makeLikeArray has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public static function makeLikeArray( $filterEntry, $protocol = 'http://' ) {
        $services = MediaWikiServices::getInstance();
        $db = $services->getConnectionProvider()->getReplicaDatabase();
        $likeDomain = [];
        $likePath = [];
Severity: Minor
Found in includes/ExternalLinks/LinkFilter.php - About 2 hrs 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 getAutoDeleteReason has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAutoDeleteReason( Title $title, &$hasHistory = false ) {
        if ( func_num_args() === 2 ) {
            wfDeprecated( __METHOD__ . ': $hasHistory parameter', '1.38' );
        }
        $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
Severity: Minor
Found in includes/content/ContentHandler.php - About 2 hrs 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 getLineData has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getLineData( array $block, RCCacheEntry $rcObj, array $queryParams = [] ) {
        $RCShowChangedSize = $this->getConfig()->get( MainConfigNames::RCShowChangedSize );

        $type = $rcObj->mAttribs['rc_type'];
        $data = [];
Severity: Minor
Found in includes/recentchanges/EnhancedChangesList.php - About 2 hrs 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 getLine has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLine( array $feed, RecentChange $rc, $actionComment ) {
        $services = MediaWikiServices::getInstance();
        $mainConfig = $services->getMainConfig();
        $localInterwikis = $mainConfig->get( MainConfigNames::LocalInterwikis );
        $useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
Severity: Minor
Found in includes/recentchanges/RCFeed/IRCColourfulRCFeedFormatter.php - About 2 hrs 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 handleResourceModules has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleResourceModules( $realName, $value ) {
        $defaults = [];
        $remote = $this->hasOption( 'skin' ) ? 'remoteSkinPath' : 'remoteExtPath';
        foreach ( $value as $name => $data ) {
            if ( isset( $data['localBasePath'] ) ) {
Severity: Minor
Found in maintenance/convertExtensionToRegistration.php - About 2 hrs 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 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        global $IP;
        foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
            $base = basename( $filename );
            $m = [];
Severity: Minor
Found in maintenance/language/date-formats.php - About 2 hrs 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 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->setBatchSize( $this->getOption( 'batch-size', $this->getBatchSize() ) );

        $sleep = (int)$this->getOption( 'sleep', 10 );
        $fromId = $this->getOption( 'from-id', null );
Severity: Minor
Found in maintenance/deleteAutoPatrolLogs.php - About 2 hrs 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

File SpecialMergeHistory.php has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/specials/SpecialMergeHistory.php - About 2 hrs to fix

    File MessagesZh.php has 288 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Chinese (中文)
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesZh.php - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
              c2 = str.charCodeAt(m_pos + 1);
              if ((c2 & 0xfc00) === 0xdc00) {
                c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
                m_pos++;
      Severity: Major
      Found in resources/lib/pako/pako_deflate.js and 1 other location - About 2 hrs to fix
      resources/lib/pako/pako_deflate.js on lines 3545..3551

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 93.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language