wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function getProtectionInfo has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function getProtectionInfo() {
        $this->protections = [];
        $db = $this->getDB();

        // Get normal protections for existing titles
Severity: Minor
Found in includes/api/ApiQueryInfo.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 performUpload has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function performUpload( $warnings ) {
        // Use comment as initial page text by default
        $this->mParams['text'] ??= $this->mParams['comment'];

        /** @var LocalFile $file */
Severity: Minor
Found in includes/api/ApiUpload.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 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $user = $this->getUserForUpdatesOrNull();
        if ( !$user || !$user->isNamed() ) {
            $this->dieWithError(
                [ 'apierror-mustbeloggedin', $this->msg( 'action-editmyoptions' ) ], 'notloggedin'
Severity: Minor
Found in includes/api/ApiOptionsBase.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 __construct has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $context = null, $enableWrite = false, $internal = null ) {
        if ( $context === null ) {
            $context = RequestContext::getMain();
        } elseif ( $context instanceof WebRequest ) {
            // BC for pre-1.19
Severity: Minor
Found in includes/api/ApiMain.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 processIndividual has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processIndividual( $type, $params, $id ) {
        $user = $this->getUser();
        $idResult = [ $type => $id ];

        // validate the ID
Severity: Minor
Found in includes/api/ApiTag.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 getModuleSourceInfo has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getModuleSourceInfo() {
        if ( $this->mModuleSource !== false ) {
            return $this->mModuleSource;
        }

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

    protected function addWarningOrError( $tag, $modulePath, $msg ) {
        $value = self::stripMarkup( $msg->text() );

        if ( $tag === 'error' ) {
            // In BC mode, only one error
Severity: Minor
Found in includes/api/ApiErrorFormatter_BackCompat.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 formatRevisionRow has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function formatRevisionRow( $row, $earliestLiveTime, $remaining ) {
        $revRecord = $this->revisionStore->newRevisionFromArchiveRow(
                $row,
                IDBAccessObject::READ_NORMAL,
                $this->mTargetObj
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 getBlockListPager has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getBlockListPager() {
        $conds = [];
        $db = $this->getDB();

        if ( $this->target !== '' ) {
Severity: Minor
Found in includes/specials/SpecialBlockList.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 parseParams has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseParams( $par ) {
        $bits = preg_split( '/\s*,\s*/', trim( $par ) );
        foreach ( $bits as $bit ) {
            $m = [];
            if ( $bit === 'shownav' ) {
Severity: Minor
Found in includes/specials/SpecialNewPages.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 showPermissionInternal has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function showPermissionInternal( array $messages, $action = null ) {
        $services = MediaWikiServices::getInstance();
        $groupPermissionsLookup = $services->getGroupPermissionsLookup();

        // For some actions (read, edit, create and upload), display a "login to do this action"
Severity: Minor
Found in includes/Output/OutputPage.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 save has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function save(
        ParserOutput $parserOutput,
        PageRecord $page,
        $popts,
        $cacheTime = null,
Severity: Minor
Found in includes/parser/ParserCache.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 displaytitle has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function displaytitle( $parser, $text = '', $uarg = '' ) {
        $restrictDisplayTitle = MediaWikiServices::getInstance()->getMainConfig()
            ->get( MainConfigNames::RestrictDisplayTitle );

        static $magicWords = null;
Severity: Minor
Found in includes/parser/CoreParserFunctions.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 mergeMapStrategy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private static function mergeMapStrategy( array $a, array $b ): array {
        foreach ( $b as $key => $bValue ) {
            if ( !array_key_exists( $key, $a ) ) {
                $a[$key] = $bValue;
            } elseif (
Severity: Minor
Found in includes/parser/ParserOutput.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 getWhere has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWhere( IReadableDatabase $db, $key, $users, $useId = true ) {
        $this->checkDeprecation( $key );

        $tables = [];
        $conds = [];
Severity: Minor
Found in includes/user/ActorMigrationBase.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 verifyFile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function verifyFile() {
        $config = MediaWikiServices::getInstance()->getMainConfig();
        $verifyMimeType = $config->get( MainConfigNames::VerifyMimeType );
        $disableUploadScriptChecks = $config->get( MainConfigNames::DisableUploadScriptChecks );
        $status = $this->verifyPartialFile();
Severity: Minor
Found in includes/upload/UploadBase.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 getBackendPaths has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBackendPaths( array $paths, $latest = true ) {
        $db = $this->getDB( $latest ? DB_PRIMARY : DB_REPLICA );

        // @TODO: batching
        $resolved = [];
Severity: Minor
Found in includes/filerepo/FileBackendDBRepoWrapper.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 detectVirus has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function detectVirus( $file ) {
        global $wgOut;
        $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
        $antivirus = $mainConfig->get( MainConfigNames::Antivirus );
        $antivirusSetup = $mainConfig->get( MainConfigNames::AntivirusSetup );
Severity: Minor
Found in includes/upload/UploadBase.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 buildPageObjects has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildPageObjects( array $searchResponse ): array {
        $pageInfos = [];
        foreach ( $searchResponse as $response ) {
            $isSearchResult = $response instanceof SearchResult;
            if ( $isSearchResult ) {
Severity: Minor
Found in includes/Rest/Handler/SearchHandler.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 checkPolicies has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkPolicies( UserIdentity $user, $password, $policies, $policyCheckFunctions ) {
        $status = Status::newGood( [] );
        $forceChange = false;
        $suggestChangeOnLogin = false;
        $legacyUser = MediaWikiServices::getInstance()
Severity: Minor
Found in includes/password/UserPasswordPolicy.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

Severity
Category
Status
Source
Language