wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    public function execute() {
        if ( !$this->getUser()->isRegistered() ) {
            $this->dieWithError( 'apierror-mustbeloggedin-uploadstash', 'notloggedin' );
        }

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

    private function matchUrlPattern( $url, array $patterns ) {
        if ( isset( $patterns[ $url ] ) ) {
            return true;
        }

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

    protected function executeGenderCacheFromResultWrapper(
        IResultWrapper $res, $fname = __METHOD__, $fieldPrefix = 'page'
    ) {
        if ( !$res->numRows() ) {
            return;
Severity: Minor
Found in includes/api/ApiQueryBase.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 getAllowedParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllowedParams() {
        $slotRoles = $this->slotRoleRegistry->getKnownRoles();
        sort( $slotRoles, SORT_STRING );

        // Parameters for the 'from' and 'to' content
Severity: Minor
Found in includes/api/ApiComparePages.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 handleParamNormalization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleParamNormalization( $paramName, $value, $rawValue ) {
        parent::handleParamNormalization( $paramName, $value, $rawValue );

        if ( $paramName === 'titles' ) {
            // For the 'titles' parameter, we want to split it like ApiBase would
Severity: Minor
Found in includes/api/ApiPageSet.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 addRequestedFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addRequestedFields( $force = [] ) {
        $result = $this->getResult();

        $requestid = $this->getParameter( 'requestid' );
        if ( $requestid !== null ) {
Severity: Minor
Found in includes/api/ApiMain.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $params = $this->extractRequestParams();
        $wikiPage = $this->getTitleOrPageId( $params );
        $title = $wikiPage->getTitle();
        $this->getErrorFormatter()->setContextTitle( $title );
Severity: Minor
Found in includes/api/ApiChangeContentModel.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 setCacheMode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setCacheMode( $mode ) {
        if ( !in_array( $mode, [ 'private', 'public', 'anon-public-user-private' ] ) ) {
            wfDebug( __METHOD__ . ": unrecognised cache mode \"$mode\"" );

            // Ignore for forwards-compatibility
Severity: Minor
Found in includes/api/ApiMain.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 setupExternalResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setupExternalResponse( $module, $params ) {
        $validMethods = [ 'GET', 'HEAD', 'POST', 'OPTIONS' ];
        $request = $this->getRequest();

        if ( !in_array( $request->getMethod(), $validMethods ) ) {
Severity: Minor
Found in includes/api/ApiMain.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 fixHelpLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function fixHelpLinks( $html, $helptitle = null, $localModules = [] ) {
        return HtmlHelper::modifyElements(
            $html,
            static function ( SerializerNode $node ): bool {
                return $node->name === 'a'
Severity: Minor
Found in includes/api/ApiHelp.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 getBlockDetails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getBlockDetails(
        Block $block,
        $language = null
    ) {
        $language ??= $this->getLanguage();
Severity: Minor
Found in includes/api/ApiBlockInfoTrait.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Check if change language feature is enabled
        if ( !$this->getConfig()->get( MainConfigNames::PageLanguageUseDB ) ) {
            $this->dieWithError( 'apierror-pagelang-disabled' );
        }
Severity: Minor
Found in includes/api/ApiSetPageLanguage.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 getWatchlistValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getWatchlistValue(
        string $watchlist,
        Title $title,
        User $user,
        ?string $userOption = null
Severity: Minor
Found in includes/api/ApiWatchlistTrait.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 appendLanguageVariants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function appendLanguageVariants( $property ) {
        $langNames = $this->languageConverterFactory->isConversionDisabled() ? [] :
            LanguageConverter::$languagesWithVariants;
        sort( $langNames );

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

    protected function appendDbReplLagInfo( $property, $includeAll ) {
        $data = [];
        $showHostnames = $this->getConfig()->get( MainConfigNames::ShowHostnames );
        if ( $includeAll ) {
            if ( !$showHostnames ) {
Severity: Minor
Found in includes/api/ApiQuerySiteinfo.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 modifyTableSpecificBlobsForAdd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function modifyTableSpecificBlobsForAdd(
        IDatabase $db,
        string $ptable,
        float $mtime,
        array $argsByKey,
Severity: Minor
Found in includes/objectcache/SqlBagOStuff.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 showConvenienceLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function showConvenienceLinks() {
        $linkRenderer = $this->getLinkRenderer();
        # Give a link to the logs/hist for this page
        if ( $this->targetObj ) {
            // Also set header tabs to be for the target.
Severity: Minor
Found in includes/specials/SpecialRevisionDelete.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 buildMultiUpsertSetForOverwrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildMultiUpsertSetForOverwrite( IDatabase $db, string $mt ) {
        $expressionsByColumn = [
            'value'   => $db->buildExcludedValue( 'value' ),
            'exptime' => $db->buildExcludedValue( 'exptime' )
        ];
Severity: Minor
Found in includes/objectcache/SqlBagOStuff.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 addBlockInfoToStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function addBlockInfoToStatus( StatusValue $status, Authority $user = null ) {
        if ( $status instanceof PermissionStatus ) {
            $block = $status->getBlock();
        } else {
            $user = $user ?: $this->getAuthority();
Severity: Minor
Found in includes/api/ApiBase.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 tryShowFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryShowFile( $archiveName ) {
        $repo = $this->repoGroup->getLocalRepo();
        $oimage = $repo->newFromArchiveName( $this->targetObj, $archiveName );
        $oimage->load();
        // Check if user is allowed to see this file
Severity: Minor
Found in includes/specials/SpecialRevisionDelete.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