wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function getEligibleRevisionIdentifiersById has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEligibleRevisionIdentifiersById( EntityId $entityId, array $ids ): array {
        $revisions = [];

        foreach ( $ids as $id ) {
            $timestamp = $this->revisionLookup->getTimestampFromId( $id );

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

    public function fetchIds( $limit ) {
        Assert::parameter( is_int( $limit ) && $limit > 0, '$limit', '$limit must be a positive integer' );

        $dbr = $this->db->connections()->getReadConnection();
        $queryBuilder = $dbr->newSelectQueryBuilder();
Severity: Minor
Found in repo/includes/Store/Sql/SqlEntityIdPager.php - About 35 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 addLinksToOutput has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function addLinksToOutput( array $links, ParserOutput $parserOutput ) {
        foreach ( $links as $siteId => $siteLink ) {
            $page = $siteLink->getPageName();
            $targetSite = $this->siteLookup->getSite( $siteId );

Severity: Minor
Found in client/includes/Hooks/LangLinkHandler.php - About 35 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 filterRepoLinksByGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function filterRepoLinksByGroup( array $repoLinks, array $allowedGroups ) {
        foreach ( $repoLinks as $wiki => $link ) {
            if ( !$this->siteLookup->getSite( $wiki ) ) {
                unset( $repoLinks[$wiki] );
                continue;
Severity: Minor
Found in client/includes/Hooks/LangLinkHandler.php - About 35 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 getConflictForSiteLink has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getConflictForSiteLink( string $itemId, SiteLink $siteLink ): ?array {
        $key = $this->cacheKey( $siteLink );
        $ttl = BagOStuff::TTL_MINUTE;
        $conflict = [
            'siteId' => $siteLink->getSiteId(),
Severity: Minor
Found in repo/includes/Store/BagOStuffSiteLinkConflictLookup.php - About 35 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 overridePageMetaTags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function overridePageMetaTags( OutputPage $outputPage ) {
        $meta = $this->getOutput()->getProperty( 'wikibase-meta-tags' );

        if ( $this->isDiff() ) {
            if ( isset( $meta['title'] ) ) {
Severity: Minor
Found in repo/includes/Actions/ViewEntityAction.php - About 35 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 getUsedEntityIdStrings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getUsedEntityIdStrings( array $idStrings ): array {
        // Note: We need to use one (sub)query per entity here, per T116404
        $subQueries = $this->getUsedEntityIdStringsQueries( $idStrings );
        $readConnection = $this->db->connections()->getReadConnection();

Severity: Minor
Found in client/includes/Usage/Sql/EntityUsageTable.php - About 35 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 collectValuesInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function collectValuesInternal( array $data, array $flippedIgnoreArray, array &$values = [] ) {
        foreach ( $data as $key => $value ) {
            if ( isset( $flippedIgnoreArray[$key] ) ) {
                continue;
            }
Severity: Minor
Found in repo/includes/ArrayValueCollector.php - About 35 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 localLinksToArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function localLinksToArray( array $flatLinks ) {
        $links = [];
        $sites = $this->siteLookup->getSites();

        foreach ( $flatLinks as $s ) {
Severity: Minor
Found in client/includes/Hooks/LangLinkHandler.php - About 35 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 getConflictsForItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getConflictsForItem( ItemId $itemId, SiteLinkList $siteLinkList, int $db = null ) {
        if ( $siteLinkList->isEmpty() ) {
            return [];
        }

Severity: Minor
Found in repo/includes/Store/Sql/SqlSiteLinkConflictLookup.php - About 35 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 addLinkHeaders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function addLinkHeaders( OutputPage $outputPage ) {
        if ( !$this->isEditable() ) {
            return;
        }
        $variables = $outputPage->getJsConfigVars();
Severity: Minor
Found in repo/includes/Actions/ViewEntityAction.php - About 35 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 checkCanCreateRedirect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkCanCreateRedirect( EntityId $entityId ): void {
        try {
            $revision = $this->entityRevisionLookup->getEntityRevision(
                $entityId,
                0,
Severity: Minor
Found in repo/includes/Interactors/EntityRedirectCreationInteractor.php - About 35 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 getEntityIdMatchingSearchTerm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEntityIdMatchingSearchTerm( $term, $entityType ) {
        $entityId = null;
        foreach ( $this->getEntityIdCandidatesForSearchTerm( $term ) as $candidate ) {
            try {
                $entityId = $this->idParser->parse( $candidate );
Severity: Minor
Found in repo/includes/Api/EntityIdSearchHelper.php - About 35 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 validateParameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function validateParameters( array $params ): void {
        if ( $params['snaktype'] === 'value' xor isset( $params['value'] ) ) {
            if ( $params['snaktype'] === 'value' ) {
                $this->errorReporter->dieWithError(
                    [ 'wikibase-api-claim-value-missing' ],
Severity: Minor
Found in repo/includes/Api/CreateClaim.php - About 35 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 filterEntitySerializationUsingSiteIds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function filterEntitySerializationUsingSiteIds(
        array $serialization,
        array $siteIds = null
    ) {
        if ( $siteIds && array_key_exists( 'sitelinks', $serialization ) ) {
Severity: Minor
Found in repo/includes/Api/ResultBuilder.php - About 35 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 addRevisionIdFromStatusToResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addRevisionIdFromStatusToResult( Status $status, $path, $oldRevId = null ) {
        $value = $status->getValue();

        if ( isset( $value['revision'] ) ) {
            if ( $value['revision'] instanceof EntityRevision ) {
Severity: Minor
Found in repo/includes/Api/ResultBuilder.php - About 35 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 addTermsToResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function addTermsToResult( array $pagesToEntityIds, array $termGroups ): void {
        $result = $this->getResult();

        foreach ( $pagesToEntityIds as $currentPage => $entityId ) {
            if ( !isset( $termGroups[$currentPage] ) ) {
Severity: Minor
Found in repo/includes/Api/EntityTerms.php - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $value ) {
        $result = Result::newSuccess();

        foreach ( $this->validators as $validator ) {
            $subResult = $validator->validate( $value );
Severity: Minor
Found in repo/includes/Validators/CompositeValidator.php - About 35 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 executeInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function executeInternal(): void {
        $params = $this->extractRequestParams();
        $statement = $this->getStatementFromParams( $params );
        $guid = $statement->getGuid();

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

    protected function applyChangeOp( ChangeOp $changeOp, EntityDocument $entity, Summary $summary = null ): ChangeOpResult {
        try {
            // NOTE: Always validate modification against the current revision, if it exists!
            //       Otherwise, we may miss e.g. a combination of language/label/description
            //       that was already taken.
Severity: Minor
Found in repo/includes/Api/ModifyEntity.php - About 35 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