wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function rebuild has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function rebuild() {
        $ticket = $this->db->getEmptyTransactionTicket( __METHOD__ );

        while ( true ) {
            $propertyIds = $this->idPager->fetchIds( $this->batchSize );
Severity: Minor
Found in repo/includes/Store/PropertyTermsRebuilder.php - About 55 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 getEntityIdsToFetch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEntityIdsToFetch( array $entityIds, array $termTypes, array $languageCodes ): array {
        /** @var EntityId[] serialization -> EntityId */
        $entityIdsToFetch = [];

        foreach ( $entityIds as $entityId ) {
Severity: Minor
Found in repo/includes/FederatedProperties/ApiPrefetchingTermLookup.php - About 55 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 getTitleForNotification has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTitleForNotification( DiffOp $siteLinkDiffOp ) {
        if ( $siteLinkDiffOp instanceof DiffOpAdd ) {
            $new = $siteLinkDiffOp->getNewValue();
            $newTitle = Title::newFromText( $new );
            return $this->canNotifyForTitle( $newTitle ) ? $newTitle : false;
Severity: Minor
Found in client/includes/Hooks/EchoNotificationsHandlers.php - About 55 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 handleDisabledUsages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleDisabledUsages( array $usages ): array {
        $newUsages = [];

        foreach ( $usages as $usage ) {
            if ( !( $usage instanceof EntityUsage ) ) {
Severity: Minor
Found in client/includes/Usage/Sql/SqlUsageTracker.php - About 55 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 rebuildSiteLinks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function rebuildSiteLinks( array $itemIds ): int {
        $this->entityPrefetcher->prefetch( $itemIds );

        $c = 0;
        foreach ( $itemIds as $itemId ) {
Severity: Minor
Found in repo/includes/Store/Sql/ItemsPerSiteBuilder.php - About 55 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 adjustFlagsForMCR has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function adjustFlagsForMCR( $flags, $parentRevision, $slotRole ) {
        if ( $flags & EDIT_UPDATE ) {
            if ( !$parentRevision ) {
                throw new StorageException( 'Can\'t perform an update with no parent revision' );
            }
Severity: Minor
Found in repo/includes/Store/Sql/WikiPageEntityStore.php - About 55 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 addEntityRevision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function addEntityRevision(
        $sourceEntityIdSerialization,
        EntityRevision $entityRevision,
        $props = 'all',
        array $filterSiteIds = null,
Severity: Minor
Found in repo/includes/Api/ResultBuilder.php - About 55 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 getForm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getForm( EntityDocument $entity = null ) {
        if ( $this->page === null ) {
            $this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
        }
        if ( !$this->badges ) {
Severity: Minor
Found in repo/includes/Specials/SpecialSetSiteLink.php - About 55 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 saveRedirect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function saveRedirect(
        EntityRedirect $redirect,
        FormatableSummary $summary,
        IContextSource $context,
        bool $bot,
Severity: Minor
Found in repo/includes/Interactors/EntityRedirectCreationInteractor.php - About 55 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 createEntity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function createEntity( $entityType, EntityId $customId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
        if ( $customId ) {
            $entityType = $customId->getEntityType();
        } elseif ( !$entityType ) {
            $this->errorReporter->dieError(
Severity: Minor
Found in repo/includes/Api/EntitySavingHelper.php - About 55 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 modifyEntity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
        if ( !( $entity instanceof Item ) ) {
            $this->errorReporter->dieError( "The given entity is not an item", "not-item" );
        }

Severity: Minor
Found in repo/includes/Api/SetSiteLink.php - About 55 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 resolveMentionedEntities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveMentionedEntities(): void {
        $hasRedirect = false;

        $this->markStubEntityDataForPrefetching( $this->entitiesResolved );

Severity: Minor
Found in repo/includes/Rdf/RdfBuilder.php - About 55 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 onShowSearchHit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function onShowSearchHit( $searchPage, $result,
        $terms, &$link, &$redirect, &$section, &$extract, &$score, &$size, &$date, &$related,
        &$html
    ): void {
        if ( $result instanceof ExtendedResult ) {
Severity: Minor
Found in repo/includes/Hooks/ShowSearchHitHandler.php - About 55 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 addEntityPageProps has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function addEntityPageProps( EntityDocument $entity ): void {
        if ( !$this->shouldProduce( RdfProducer::PRODUCE_PAGE_PROPS ) ) {
            return;
        }
        $pagePropertyDefs = $this->getPagePropertyDefs();
Severity: Minor
Found in repo/includes/Rdf/RdfBuilder.php - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( EntityDocument $entity ) {
        $languageValidator = $this->termValidatorFactory->getAliasLanguageValidator();
        $termValidator = $this->termValidatorFactory->getAliasValidator();

        // check that the language is valid
Severity: Minor
Found in repo/includes/ChangeOp/ChangeOpAliases.php - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $newJsonName = $this->getOption( 'config' );
        $newJson = json_decode( file_get_contents( $newJsonName ), true );
        if ( !$newJson ) {
            $this->fatalError( "Cannot load new config" );
Severity: Minor
Found in repo/maintenance/addUnitConversions.php - About 55 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 rebuild has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function rebuild() {
        $ticket = $this->db->getEmptyTransactionTicket( __METHOD__ );

        $counter = 0;
        while ( true ) {
Severity: Minor
Found in repo/maintenance/EntityQuantityUnitRebuilder.php - About 55 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 getIdentifiersCount has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIdentifiersCount( StatementList $statementList ): int {
        $identifiers = 0;
        foreach ( $statementList as $statement ) {
            $propertyId = $statement->getPropertyId();
            $propertyIdSerialization = $propertyId->getSerialization();
Severity: Minor
Found in repo/includes/Content/ItemHandler.php - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate(
        ?string $itemId,
        string $siteId,
        array $sitelink,
        string $basePath = ''
Severity: Minor
Found in repo/rest-api/src/Infrastructure/SiteLinkLookupSitelinkValidator.php - About 55 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 getTitlesForIds has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTitlesForIds( array $ids ): array {
        Assert::parameterElementType( EntityId::class, $ids, '$ids' );
        $titles = [];
        $idsByType = [];
        // get whatever federated ids or cached ids we can, and batch the rest of the ids by type
Severity: Minor
Found in repo/includes/Content/ContentHandlerEntityTitleLookup.php - About 55 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