wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Method getEntityMetaDataAccessor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getEntityMetaDataAccessor(): PrefetchingWikiPageEntityMetaDataAccessor {
        if ( $this->entityMetaDataAccessor === null ) {
            $entityNamespaceLookup = new EntityNamespaceLookup(
                $this->entitySource->getEntityNamespaceIds(),
                $this->entitySource->getEntitySlotNames()
Severity: Minor
Found in data-access/src/SingleEntitySourceServices.php - About 1 hr to fix

    Function 2d00 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    /***/ (function(module, exports, __webpack_require__) {
    
    var global = __webpack_require__("da84");
    var userAgent = __webpack_require__("342f");
    
    
    Severity: Minor
    Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr 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 getSiteLinkAddRemoveParams has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getSiteLinkAddRemoveParams( DiffOp $diffOp, $action, $siteId, Title $title = null ) {
            $params = [];
    
            if ( in_array( $action, [ 'remove', 'restore' ] ) ) {
                // Messages: wikibase-comment-remove, wikibase-comment-restore
    Severity: Minor
    Found in client/includes/RecentChanges/SiteLinkCommentCreator.php - About 1 hr 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 getTermsSerializationWithFallbackInfo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getTermsSerializationWithFallbackInfo( array $serialization ) {
            $newSerialization = $serialization;
            foreach ( $this->termFallbackChains as $requestedLanguageCode => $fallbackChain ) {
                if ( !array_key_exists( $requestedLanguageCode, $serialization ) ) {
                    $fallbackSerialization = $fallbackChain->extractPreferredValue( $serialization );
    Severity: Minor
    Found in client/includes/Serializer/ClientEntitySerializer.php - About 1 hr 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 getEntityId has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getEntityId( $pageTitle, $globalSiteId ) {
            $globalSiteId = $globalSiteId ?: $this->siteId;
            $entityId = null;
    
            if ( $globalSiteId === $this->siteId ) {

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

        private function getNamespaceNameForContentModel( string $entityContentModel ): ?string {
            foreach ( $this->namespaces as $namespace ) {
                if ( isset( $namespace['defaultcontentmodel'] ) && $namespace['defaultcontentmodel'] === $entityContentModel ) {
                    if ( array_key_exists( 'canonical', $namespace ) ) {
                        return $namespace['canonical'];
    Severity: Minor
    Found in repo/includes/FederatedProperties/ApiEntityNamespaceInfoLookup.php - About 1 hr 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 saveEntityContent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function saveEntityContent(
            EntityContent $entityContent,
            User $user,
            $summary = '',
            $flags = 0,
    Severity: Minor
    Found in repo/includes/Store/Sql/WikiPageEntityStore.php - About 1 hr 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 filterImplicitUsages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function filterImplicitUsages(
            array $itemIdsByPageId,
            array $contentLanguagesByPageId,
            array $aspects
        ): array {
    Severity: Minor
    Found in client/includes/Usage/ImplicitDescriptionUsageLookup.php - About 1 hr 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 getEntityId has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getEntityId( array $params ): EntityId {
            $entityId = null;
    
            foreach ( $params['claim'] as $guid ) {
                if ( !$this->modificationHelper->validateStatementGuid( $guid ) ) {
    Severity: Minor
    Found in repo/includes/Api/RemoveClaims.php - About 1 hr 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 assertNoPipeCharacterInAliases has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function assertNoPipeCharacterInAliases( Fingerprint $fingerprint ) {
            if ( $this->aliases ) {
                if ( $fingerprint->hasAliasGroup( $this->languageCode ) ) {
                    $aliasesInLang = $fingerprint->getAliasGroup( $this->languageCode )->getAliases();
                    foreach ( $aliasesInLang as $alias ) {
    Severity: Minor
    Found in repo/includes/Specials/SpecialSetLabelDescriptionAliases.php - About 1 hr 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 formatResult has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function formatResult( IResultWrapper $res, int $limit, array $props ): void {
            $currentEntity = null;
            $count = 0;
            $result = $this->getResult();
            $props = array_flip( $props );
    Severity: Minor
    Found in repo/includes/Api/ListSubscribers.php - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
            $data = $preparedParameters[self::PARAM_DATA];
    
            $exists = $this->entityExists( $entity->getId() );
    
    
    Severity: Minor
    Found in repo/includes/Api/EditEntity.php - About 1 hr 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 validateBadgeSerialization has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function validateBadgeSerialization( array $serialization ) {
            foreach ( $serialization as $badgeSerialization ) {
                if ( !is_string( $badgeSerialization ) ) {
                    throw new ChangeOpDeserializationException(
                        'Badges: a string was expected, but not found',

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

        private function parseDate( $input ) {
            $pattern = $this->parseDateFormat( $this->getDateFormat() );
    
            AtEase::suppressWarnings();
            $success = preg_match( $pattern, $input, $matches );
    Severity: Minor
    Found in repo/includes/Parsers/DateFormatParser.php - About 1 hr 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 convertUnit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function convertUnit( $unit, $convertUnits, $coherentUnits, $unitUsage, &$reconvert ) {
            $unit['unit'] = substr( $unit['unit'], $this->baseLen );
            $unit['siUnit'] = substr( $unit['siUnit'], $this->baseLen );
    
            if ( isset( $convertUnits[$unit['unit']] ) ) {
    Severity: Minor
    Found in repo/maintenance/updateUnits.php - About 1 hr 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 formatSnak has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function formatSnak( Snak $snak ) {
            $warningText = '';
            try {
                return $this->snakFormatter->formatSnak( $snak );
            } catch ( MismatchingDataValueTypeException $ex ) {
    Severity: Minor
    Found in lib/includes/Formatters/ErrorHandlingSnakFormatter.php - About 1 hr 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 loadRevisionInformation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function loadRevisionInformation( array $entityIds, $mode ): array {
            $rows = [];
    
            $this->assertCanHandleEntityIds( $entityIds );
    
    
    Severity: Minor
    Found in lib/includes/Store/Sql/WikiPageEntityMetaDataLookup.php - About 1 hr 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 loadLatestRevisionIds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function loadLatestRevisionIds( array $entityIds, $mode ): array {
            $revisionIds = [];
    
            $this->assertCanHandleEntityIds( $entityIds );
    
    
    Severity: Minor
    Found in lib/includes/Store/Sql/WikiPageEntityMetaDataLookup.php - About 1 hr 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 getPrefetchedTermsFromLookup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getPrefetchedTermsFromLookup(
            array $entitiesToPrefetch,
            array $languagesToPrefetch,
            array $termTypes
        ): array {
    Severity: Minor
    Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 1 hr 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 getDeserialized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getDeserialized( array $serialization ) {
            $statementList = new StatementList();
    
            foreach ( $serialization as $key => $statementArray ) {
                if ( is_string( $key ) ) {

    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