wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function executePath has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function executePath( $path, IContextSource $context, $including = false,
        LinkRenderer $linkRenderer = null
    ) {
        if ( $path instanceof PageReference ) {
            $path = $path->getDBkey();
Severity: Minor
Found in includes/specialpage/SpecialPageFactory.php - About 1 hr 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 params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function params( ...$args ) {
        // If $args has only one entry and it's an array, then it's either a
        // non-varargs call or it happens to be a call with just a single
        // "special" parameter. Since the "special" parameters don't have any
        // numeric keys, we'll test that to differentiate the cases.
Severity: Minor
Found in includes/Message/Message.php - About 1 hr 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 setCookie has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function setCookie( $name, $value, $expire = 0, $options = [] ) {
        $services = MediaWikiServices::getInstance();
        $mainConfig = $services->getMainConfig();
        $cookiePath = $mainConfig->get( MainConfigNames::CookiePath );
        $cookiePrefix = $mainConfig->get( MainConfigNames::CookiePrefix );
Severity: Minor
Found in includes/Request/WebResponse.php - About 1 hr 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 wfRecursiveRemoveDir has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function wfRecursiveRemoveDir( $dir ) {
    // taken from https://www.php.net/manual/en/function.rmdir.php#98622
    if ( is_dir( $dir ) ) {
        $objects = scandir( $dir );
        foreach ( $objects as $object ) {
Severity: Minor
Found in includes/GlobalFunctions.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function run() {
        $dbw = $this->lbFactory->getPrimaryDatabase();
        $ticket = $this->lbFactory->getEmptyTransactionTicket( __METHOD__ );
        $table = $this->params['table'];
        $column = $this->params['column'];
Severity: Minor
Found in includes/RenameUser/RenameUserJob.php - About 1 hr 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 dirIsExecutable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function dirIsExecutable( $dir, $url ) {
        $scriptTypes = [
            'php' => [
                "<?php echo 'exec';",
                "#!/var/env php\n<?php echo 'exec';",
Severity: Minor
Found in includes/installer/Installer.php - About 1 hr 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 initQueryBuilderForTable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function initQueryBuilderForTable( string $table, string $select ): SelectQueryBuilder {
        $prefix = $this->getPrefix( $table );
        $queryBuilder = $this->getDB()->newSelectQueryBuilder();
        $joinPageTable = $select !== 'ids';

Severity: Minor
Found in includes/cache/BacklinkCache.php - About 1 hr 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 showParamsConflicting has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function showParamsConflicting( array $show ) {
        return ( isset( $show[WatchedItemQueryService::FILTER_MINOR] )
            && isset( $show[WatchedItemQueryService::FILTER_NOT_MINOR] ) )
        || ( isset( $show[WatchedItemQueryService::FILTER_BOT] )
            && isset( $show[WatchedItemQueryService::FILTER_NOT_BOT] ) )
Severity: Minor
Found in includes/api/ApiQueryWatchlist.php - About 1 hr 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 addInterwikiResults has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function addInterwikiResults(
        ISearchResultSet $matches, ApiResult $apiResult, $prop,
        $section, $type
    ) {
        $totalhits = null;
Severity: Minor
Found in includes/api/ApiQuerySearch.php - About 1 hr 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 getRestrictionData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getRestrictionData( IResultWrapper $result, $limit ) {
        $partialIds = [];
        $count = 0;
        foreach ( $result as $row ) {
            if ( ++$count <= $limit && !( $row->ipb_sitewide ?? $row->bl_sitewide ) ) {
Severity: Minor
Found in includes/api/ApiQueryBlocks.php - About 1 hr 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 getRateLimits has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getRateLimits( bool $applyNoRateLimit ) {
        $retval = [
            ApiResult::META_TYPE => 'assoc',
        ];

Severity: Minor
Found in includes/api/ApiQueryUserInfo.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        # Only operate on existing pages
        $pages = $this->getPageSet()->getGoodPages();

        $params = $this->extractRequestParams();
Severity: Minor
Found in includes/api/ApiQueryPageProps.php - About 1 hr 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 mergeThumbParams has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
        if ( $thumbParams === null ) {
            // No scaling requested
            return null;
        }
Severity: Minor
Found in includes/api/ApiQueryImageInfo.php - About 1 hr 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 stripMetadataNonRecursive has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function stripMetadataNonRecursive( $data, &$metadata = null ) {
        if ( !is_array( $metadata ) ) {
            $metadata = [];
        }
        if ( is_array( $data ) || is_object( $data ) ) {
Severity: Minor
Found in includes/api/ApiResult.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $user = $this->getUser();

        if ( !$user->isRegistered() ) {
            $this->dieWithError( 'apierror-mustbeloggedin-uploadstash', 'stashnotloggedin' );
Severity: Minor
Found in includes/api/ApiQueryMyStashedFiles.php - About 1 hr 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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validate( $key, &$value ) {
        switch ( $this->getPrefsKinds()[$key] ) {
            case 'registered':
                // Regular option.
                if ( $value === null ) {
Severity: Minor
Found in includes/api/ApiOptionsBase.php - About 1 hr 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 errorMessagesFromException has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function errorMessagesFromException( Throwable $e, $type = 'error' ) {
        $messages = [];
        if ( $e instanceof ApiUsageException ) {
            foreach ( $e->getStatusValue()->getMessages( $type ) as $msg ) {
                $messages[] = ApiMessage::create( $msg );
Severity: Minor
Found in includes/api/ApiMain.php - About 1 hr 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 instantiateModules has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function instantiateModules( &$modules, $param ) {
        $wasPosted = $this->getRequest()->wasPosted();
        if ( isset( $this->mParams[$param] ) ) {
            foreach ( $this->mParams[$param] as $moduleName ) {
                $instance = $this->mModuleMgr->getModule( $moduleName, $param );
Severity: Minor
Found in includes/api/ApiQuery.php - About 1 hr 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 getTitleOrPageId has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTitleOrPageId( $params, $load = false ) {
        $this->requireOnlyOneParameter( $params, 'title', 'pageid' );

        $pageObj = null;
        if ( isset( $params['title'] ) ) {
Severity: Minor
Found in includes/api/ApiBase.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $request = $this->getRequest();
        $out = $this->getOutput();

        // Fetch the search term
Severity: Minor
Found in includes/specials/SpecialSearch.php - About 1 hr 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