wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    public get dataValue() {
        return ( pathToSnak: PathToSnak ): DataValue | null => {
            const snak = pathToSnak.resolveSnakInStatement( this.state );
            return snak?.datavalue ?? null;
        };
Severity: Major
Found in client/data-bridge/src/store/statements/getters.ts and 3 other locations - About 1 hr to fix
client/data-bridge/src/store/statements/getters.ts on lines 39..44
client/data-bridge/src/store/statements/getters.ts on lines 53..58
client/data-bridge/src/store/statements/getters.ts on lines 60..65

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    public get snakType() {
        return ( pathToSnak: PathToSnak ): SnakType | null => {
            const snak = pathToSnak.resolveSnakInStatement( this.state );
            return snak?.snaktype ?? null;
        };
Severity: Major
Found in client/data-bridge/src/store/statements/getters.ts and 3 other locations - About 1 hr to fix
client/data-bridge/src/store/statements/getters.ts on lines 39..44
client/data-bridge/src/store/statements/getters.ts on lines 46..51
client/data-bridge/src/store/statements/getters.ts on lines 60..65

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public constructor( mWHooks: HookRegistry, taintedChecker: TaintedChecker, statementTracker: StatementTracker ) {
        this.mwHooks = mWHooks;
        this.taintedChecker = taintedChecker;
        this.statementTracker = statementTracker;
    }
Severity: Major
Found in view/lib/wikibase-tainted-ref/src/MWHookHandler.ts and 1 other location - About 1 hr to fix
client/data-bridge/src/data-access/RepoRouter.ts on lines 12..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    public get rank() {
        return ( pathToStatement: PathToStatement ): Rank | null => {
            const statement = pathToStatement.resolveStatement( this.state );
            return statement?.rank ?? null;
        };
Severity: Major
Found in client/data-bridge/src/store/statements/getters.ts and 3 other locations - About 1 hr to fix
client/data-bridge/src/store/statements/getters.ts on lines 46..51
client/data-bridge/src/store/statements/getters.ts on lines 53..58
client/data-bridge/src/store/statements/getters.ts on lines 60..65

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Consider simplifying this complex logical expression.
Open

        if ( ( !structureEditorFactory || !structureEditorFactory.getAdder )
            || ( !messageProvider || !messageProvider.getMessage )
            || !Array.isArray( userLanguages )
            || ( vocabularyLookupApiUrl && typeof vocabularyLookupApiUrl !== 'string'
            || !commonsApiUrl )
Severity: Critical
Found in view/resources/wikibase/view/ViewFactory.js - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getDescriptions( EntityId $entityId ): ?Descriptions {
            try {
                $descriptions = $this->termLookup->getDescriptions( $entityId, $this->termLanguages->getLanguages() );
            } catch ( TermLookupException $e ) {
                // this probably means that the entity does not exist, which should be checked prior to calling this method
    repo/rest-api/src/Infrastructure/DataAccess/TermLookupEntityTermsRetriever.php on lines 55..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getLabels( EntityId $entityId ): ?Labels {
            try {
                $labels = $this->termLookup->getLabels( $entityId, $this->termLanguages->getLanguages() );
            } catch ( TermLookupException $e ) {
                // this probably means that the entity does not exist, which should be checked prior to calling this method
    repo/rest-api/src/Infrastructure/DataAccess/TermLookupEntityTermsRetriever.php on lines 80..93

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function _onSiteSelectorChangeHandler has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _onSiteSelectorChangeHandler: function () {
                var apiUrl,
                    $page = $( '#wbclient-linkItem-page' );
    
                $page.val( '' );
    Severity: Minor
    Found in client/resources/jquery.wikibase/jquery.wikibase.linkitem.js - About 1 hr to fix

      Function WbListviewListItemAdapter has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var SELF = $.wikibase.listview.ListItemAdapter = function WbListviewListItemAdapter( options ) {
              if ( typeof options.listItemWidget !== 'function'
                  || !options.listItemWidget.prototype.widgetName
                  || !options.listItemWidget.prototype.widgetEventPrefix
              ) {

        Function value has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                value: function ( value ) {
                    if ( value !== undefined ) {
                        this.option( 'value', value );
                        return;
                    }
        Severity: Minor
        Found in view/resources/jquery/wikibase/snakview/snakview.js - About 1 hr to fix

          Function fdbc has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          /***/ (function(module, exports) {
          
          // iterable DOM collections
          // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
          module.exports = {
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

            Method doQuery has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function doQuery( array $params ): ?IResultWrapper {
                    $pages = $this->getPageSet()->getGoodPages();
                    if ( !$pages ) {
                        return null;
                    }
            Severity: Minor
            Found in client/includes/Api/ApiPropsEntityUsage.php - About 1 hr to fix

              Function actions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function actions(metricTracker) {
                return {
                  [STORE_INIT](context, guids) {
                    context.commit(SET_ALL_UNTAINTED, guids);
                    context.commit(SET_ALL_POPPERS_HIDDEN, guids);
              Severity: Minor
              Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

                Method doWikibaseHandleChange has 33 lines of code (exceeds 25 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 1 hr to fix

                  Method createSchema has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function createSchema(
                          Title $title,
                          $revisionTimestamp,
                          $entityConceptUri,
                          File $imageFile = null,
                  Severity: Minor
                  Found in client/includes/Hooks/SkinAfterBottomScriptsHandler.php - About 1 hr to fix

                    Method rebuildPropertyTerms has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function rebuildPropertyTerms( DatabaseUpdater $updater ) {
                            $localEntitySourceName = WikibaseRepo::getSettings()->getSetting( 'localEntitySourceName' );
                            $propertySource = WikibaseRepo::getEntitySourceDefinitions()
                                ->getDatabaseSourceForEntityType( 'property' );
                            if ( $propertySource === null || $propertySource->getSourceName() !== $localEntitySourceName ) {
                    Severity: Minor
                    Found in repo/includes/Store/Sql/DatabaseSchemaUpdater.php - About 1 hr to fix

                      Method getEntityIds has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getEntityIds( array $sites, array $titles, $normalize ) {
                              $ids = [];
                              $numSites = count( $sites );
                              $numTitles = count( $titles );
                      
                      
                      Severity: Minor
                      Found in repo/includes/Api/EntityByTitleHelper.php - About 1 hr to fix

                        Method showQuery has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function showQuery( array $query = [], $subPage = false ) {
                                $paging = false;
                                $out = $this->getOutput();
                        
                                if ( $this->limit == 0 && $this->offset == 0 ) {
                        Severity: Minor
                        Found in repo/includes/Specials/SpecialWikibaseQueryPage.php - About 1 hr to fix

                          Method execute has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function execute(): void {
                                  $params = $this->extractRequestParams();
                                  $user = $this->getUser();
                          
                                  $this->validateParameters( $params );
                          Severity: Minor
                          Found in repo/includes/Api/ModifyEntity.php - About 1 hr to fix

                            Method __construct has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function __construct() {
                                    parent::__construct();
                            
                                    $this->addDescription( 'Rebuilds item terms from primary persistence' );
                            
                            
                            Severity: Minor
                            Found in repo/maintenance/rebuildItemTerms.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language