wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

    public function getBadgeInfo( array $badgeIds ) {
        $classes = [];
        $labels = [];

        foreach ( $badgeIds as $badgeId ) {
Severity: Minor
Found in client/includes/Hooks/SidebarLinkBadgeDisplay.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 compareAndReturnNewUsagesAccountingForDeduplication has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function compareAndReturnNewUsagesAccountingForDeduplication(
        array $newUsages,
        array $oldUsages
    ): array {
        $result = [];
Severity: Minor
Found in client/includes/Usage/Sql/SqlUsageTracker.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 getClientWikis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getClientWikis( SettingsArray $repoSettings ): array {
        $clientWikis = $repoSettings->getSetting( 'localClientDatabases' );
        // make sure we have a mapping from siteId to database name in clientWikis:
        foreach ( $clientWikis as $siteID => $dbName ) {
            if ( is_int( $siteID ) ) {
Severity: Minor
Found in repo/includes/ChangeModification/DispatchChangesJob.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 setKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function setKeys( array $entityIds, array $termTypes, array $languageCodes ): void {
        foreach ( $entityIds as $entityId ) {
            foreach ( $termTypes as $termType ) {
                foreach ( $languageCodes as $languageCode ) {
                    $key = $this->getKey( $entityId, $termType, $languageCode );
Severity: Minor
Found in repo/includes/FederatedProperties/ApiPrefetchingTermLookup.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 doWikibaseHandleChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function doWikibaseHandleChange( Change $change ) {
        if ( $this->sendEchoNotification !== true ) {
            return false;
        }

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

    public function doHandle( Parser $parser, $shortDesc, $controlArg ) {
        $noReplace = $this->parseNoReplace( $parser, $controlArg );
        $out = $parser->getOutput();

        if ( $out->getPageProperty( 'wikibase-shortdesc' ) !== null && $noReplace ) {
Severity: Minor
Found in client/includes/Hooks/ShortDescHandler.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 getEntitySourceForConceptURI has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEntitySourceForConceptURI( $idSerialization ): ?ApiEntitySource {
        $baseUri = $this->baseUriExtractor->getBaseUriFromSerialization( $idSerialization );
        $conceptBaseURIsToSources = array_flip( $this->entitySourceDefinitions->getConceptBaseUris() );

        if ( array_key_exists( $baseUri, $conceptBaseURIsToSources ) ) {

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 getChangeOp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getChangeOp( array $preparedParameters, EntityDocument $entity ): ChangeOp {
        $changeOps = [];
        $language = $preparedParameters['language'];

        // Set the list of aliases to a user given one OR add/ remove certain entries
Severity: Minor
Found in repo/includes/Api/SetAliases.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( $subPage ) {
        parent::execute( $subPage );

        $this->checkPermissions();
        $this->checkBlocked();
Severity: Minor
Found in repo/includes/Specials/SpecialRedirectEntity.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 processArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processArguments( $subPage ) {
        $this->extractInput( $subPage );

        // Parse the 'id' parameter and throw an exception if the entity cannot be loaded
        parent::processArguments( $subPage );
Severity: Minor
Found in repo/includes/Specials/SpecialSetLabelDescriptionAliases.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 parseStringValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseStringValue( ValueParser $parser, string $value, ?ValueValidator $validator ): array {
        $result = [
            'raw' => $value,
        ];

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

    private function getOptionsObject( ?string $optionsParam ): ParserOptions {
        $parserOptions = new ParserOptions();
        $parserOptions->setOption( ValueParser::OPT_LANG, $this->getLanguage()->getCode() );

        if ( is_string( $optionsParam ) && $optionsParam !== '' ) {
Severity: Minor
Found in repo/includes/Api/ParseValue.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( $subPage ) {
        parent::execute( $subPage );
        [ $sites, $itemString ] = $this->getArguments( $subPage );

        if ( $itemString !== '' ) {
Severity: Minor
Found in repo/includes/Specials/SpecialGoToLinkedPage.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( $subPage ): void {
        $this->setHeaders();
        $this->outputHeader();

        $this->getOutput()->addWikiMsg( 'wikibase-mylanguagefallbackchain-text' );
Severity: Minor
Found in repo/includes/Specials/SpecialMyLanguageFallbackChain.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 processArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processArguments( $subPage ) {
        parent::processArguments( $subPage );

        $request = $this->getRequest();
        // explode the subpage from the format Special:SetSitelink/q123/enwiki
Severity: Minor
Found in repo/includes/Specials/SpecialSetSiteLink.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 onOutputPageParserOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function onOutputPageParserOutput( OutputPage $outputPage, ParserOutput $parserOutput ) {
        // Set in PlaceholderEmittingEntityTermsView.
        $placeholders = $parserOutput->getExtensionData( 'wikibase-view-chunks' );
        if ( $placeholders !== null ) {
            $outputPage->setProperty( 'wikibase-view-chunks', $placeholders );
Severity: Minor
Found in repo/includes/RepoHooks.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 attemptSaveEntity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function attemptSaveEntity(
        EntityDocument $entity,
        $summary,
        array $requestParams,
        IContextSource $context,
Severity: Minor
Found in repo/includes/Api/EntitySavingHelper.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 statementMainSnakAlreadyExists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function statementMainSnakAlreadyExists(
        Statement $statement,
        StatementList $existingStatements
    ): bool {
        $propertyId = $statement->getPropertyId();
Severity: Minor
Found in repo/includes/Api/SetClaim.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 mergeSearchResults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function mergeSearchResults( array $searchResults, array $newSearchResults, $limit ) {
        $searchResultEntityIdSerializations = array_keys( $searchResults );

        foreach ( $newSearchResults as $searchResultToAdd ) {
            $entityIdString = $searchResultToAdd->getEntityId()->getSerialization();
Severity: Minor
Found in repo/includes/Api/CombinedEntitySearchHelper.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $value ): Result {
        if ( !is_string( $value ) ) {
            throw new InvalidArgumentException( 'Expected a string' );
        }

Severity: Minor
Found in repo/includes/Validators/EntityUriValidator.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