wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

    private function getClientUserId( $repoUserId, array $metadata, bool $changeComesFromLocalDb ) {
        if ( $repoUserId === 0 ) {
            // Logged out on repo just copied to client
            return 0;
        }
Severity: Minor
Found in client/includes/RecentChanges/RecentChangeFactory.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 injectRCRecords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function injectRCRecords( array $titles, EntityChange $change, array $rootJobParams = [] ) {
        if ( $titles === [] ) {
            return;
        }

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

    public function getLink( Title $title, $action, $hasLangLinks, ?array $noExternalLangLinks, $prefixedId ) {
        if ( $this->canHaveLink( $title, $action, $noExternalLangLinks ) ) {
            $entityId = null;

            if ( is_string( $prefixedId ) ) {
Severity: Minor
Found in client/includes/RepoItemLinkGenerator.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 renumber has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function renumber( array &$entityArr ) {
        foreach ( $entityArr as &$value ) {
            if ( !is_array( $value ) ) {
                continue;
            }
Severity: Minor
Found in client/includes/DataAccess/Scribunto/EntityAccessor.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 onPageMoveComplete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onPageMoveComplete(
        $oldLinkTarget,
        $newLinkTarget,
        $userIdentity,
        $pageId,
Severity: Minor
Found in client/includes/Hooks/UpdateRepoHookHandler.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 isPrefetched has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function isPrefetched( EntityId $entityId, array $termTypes, array $languageCodes ): bool {
        foreach ( $termTypes as $termType ) {
            foreach ( $languageCodes as $languageCode ) {
                $key = $this->getKey( $entityId, $termType, $languageCode );
                if ( !isset( $this->termKeys[$key] ) ) {
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 indexLinksByInterwiki has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function indexLinksByInterwiki( array $links ) {
        $indexed = [];

        foreach ( $links as $link ) {
            $siteId = $link->getSiteId();
Severity: Minor
Found in client/includes/Hooks/LangLinkHandler.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 rebuild has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

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

        foreach ( $this->getIdBatches() as $itemIds ) {
            $this->progressReporter->reportMessage(
Severity: Minor
Found in repo/includes/Store/ItemTermsRebuilder.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 getOrCreatePingbackId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getOrCreatePingbackId() {
        if ( !$this->id ) {
            $dbr = $this->repoConnections->getReadConnection();

            $id = $dbr->newSelectQueryBuilder()
Severity: Minor
Found in repo/includes/WikibasePingback.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 extractSummaryProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function extractSummaryProperties( $result ): array {
        $propertyIds = [];
        foreach ( $result as $revisionRow ) {
            $comment = $this->getCommentText( $revisionRow );
            if ( $comment === null ) {
Severity: Minor
Found in repo/includes/FederatedProperties/SummaryParsingPrefetchHelper.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 function onOutputPageParserOutput( $outputPage, $parserOutput ): void {
        $title = $outputPage->getTitle();
        if ( !$title || !$this->namespaceChecker->isWikibaseEnabled( $title->getNamespace() ) ) {
            // shorten out
            return;
Severity: Minor
Found in client/includes/Hooks/SidebarHookHandler.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 generateOpHtml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function generateOpHtml( array $path, DiffOp $op ): string {
        if ( $op instanceof AtomicDiffOp ) {
            $localizedPath = $path;

            $translatedLinkSubPath = $this->messageLocalizer->msg(
Severity: Minor
Found in repo/includes/Diff/SiteLinkDiffView.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 onLoadExtensionSchemaUpdates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onLoadExtensionSchemaUpdates( $updater ) {
        $db = $updater->getDB();
        $type = $db->getType();

        if ( $type !== 'mysql' && $type !== 'sqlite' && $type !== 'postgres' ) {
Severity: Minor
Found in repo/includes/Store/Sql/DatabaseSchemaUpdater.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 buildPreliminarySidebarFromSiteLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildPreliminarySidebarFromSiteLinks( array $siteLinks ) {
        $linksByGroup = [];

        foreach ( $siteLinks as $siteLink ) {
            if ( !in_array( $siteLink->getSiteId(), $this->siteIdsToOutput ) ) {
Severity: Minor
Found in client/includes/Hooks/OtherProjectsSidebarGenerator.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 addJsModules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function addJsModules( OutputPage $outputPage, Title $title, $actionName, Skin $skin ): void {
        $user = $outputPage->getUser();

        if ( $this->hasLinkItemWidget( $user, $outputPage, $title, $actionName ) ) {
            // Add the JavaScript which lazy-loads the link item widget
Severity: Minor
Found in client/includes/Hooks/BeforePageDisplayHandler.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 onSidebarBeforeOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onSidebarBeforeOutput( $skin, &$sidebar ): void {
        // Add the 'In other projects' section
        $otherProjectsSidebar = $this->buildOtherProjectsSidebar( $skin );
        $sidebar['wikibase-otherprojects'] = $otherProjectsSidebar === null ? [] : $otherProjectsSidebar;

Severity: Minor
Found in client/includes/Hooks/SidebarHookHandler.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 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

Severity
Category
Status
Source
Language