wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

    'WikibaseRepo.DataTypeDefinitions' => function ( MediaWikiServices $services ): DataTypeDefinitions {
        $baseDataTypes = require __DIR__ . '/../lib/WikibaseLib.datatypes.php';
        $repoDataTypes = require __DIR__ . '/WikibaseRepo.datatypes.php';

        $dataTypes = wfArrayPlus2d(
Severity: Major
Found in repo/WikibaseRepo.ServiceWiring.php and 1 other location - About 1 hr to fix
client/WikibaseClient.ServiceWiring.php on lines 250..267

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 114.

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

    'WikibaseClient.DataTypeDefinitions' => function ( MediaWikiServices $services ): DataTypeDefinitions {
        $baseDataTypes = require __DIR__ . '/../lib/WikibaseLib.datatypes.php';
        $clientDataTypes = require __DIR__ . '/WikibaseClient.datatypes.php';

        $dataTypes = wfArrayPlus2d(
Severity: Major
Found in client/WikibaseClient.ServiceWiring.php and 1 other location - About 1 hr to fix
repo/WikibaseRepo.ServiceWiring.php on lines 473..490

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 114.

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 _combineResults has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _combineResults: function ( hookResults, searchResults ) {
            var self = this,
                deferred = $.Deferred(),
                ids = {},
                result = [],
Severity: Minor
Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 1 hr to fix

    Method showConfirmationForm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function showConfirmationForm( int $autoSummaryLength, int $undidRevision = 0 ): void {
            $req = $this->getRequest();
    
            $args = [
                'action' => 'submit',
    Severity: Minor
    Found in repo/includes/Actions/EditEntityAction.php - About 1 hr to fix

      Method switchForm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function switchForm( ?string $languageCode, ?string $label ): void {
              $formDescriptor = [
                  'language' => [
                      'name' => 'language',
                      'default' => $languageCode ?: '',
      Severity: Minor
      Found in repo/includes/Specials/SpecialItemDisambiguation.php - About 1 hr to fix

        Method attemptSaveEntity has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function attemptSaveEntity(
                EntityDocument $entity,
                $summary,
                array $requestParams,
                IContextSource $context,
        Severity: Minor
        Found in repo/includes/Api/EntitySavingHelper.php - About 1 hr to fix

          Method onSkinTemplateNavigationUniversal has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
                  $entityContentFactory = WikibaseRepo::getEntityContentFactory();
          
                  $title = $skinTemplate->getRelevantTitle();
          
          
          Severity: Minor
          Found in repo/includes/RepoHooks.php - About 1 hr to fix

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

              Method handleSitelinksValidationError has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function handleSitelinksValidationError( ValidationError $validationError, array $sitelinksSerialization ): void {
                      $context = $validationError->getContext();
                      $siteId = fn() => $context[ SitelinkValidator::CONTEXT_SITE_ID ];
                      switch ( $validationError->getCode() ) {
                          case SitelinksValidator::CODE_INVALID_SITELINK:

                Function apiErrorToPermissionError has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private apiErrorToPermissionError( error: ApiError, semiProtectedLevels: readonly string[] ): PermissionError {
                        assertIsApiErrorRawErrorformat( error );
                        switch ( error.code ) {
                            case 'protectedpage': {
                                const right = error.params[ 0 ] as string;

                  Function ViewFactory has 13 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          structureEditorFactory,
                          contentLanguages,
                          dataTypeStore,
                          entityIdHtmlFormatter,
                          entityIdPlainFormatter,
                  Severity: Major
                  Found in view/resources/wikibase/view/ViewFactory.js - About 1 hr to fix

                    Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            SiteLinkLookup $siteLinkLookup,
                            EntityIdLookup $entityIdLookup,
                            SettingsArray $settings,
                            UsageAccumulator $usageAccumulator,
                            EntityIdParser $entityIdParser,

                      Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              EntityChangeFactory $entityChangeFactory,
                              EntityIdParser $entityIdParser,
                              EntityIdComposer $entityIdComposer,
                              EntityIdLookup $entityIdLookup,
                              EntityTitleStoreLookup $entityTitleLookup,
                      Severity: Major
                      Found in repo/includes/Store/Sql/SqlStore.php - About 1 hr to fix

                        Method factory has 13 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
                                MediaWikiEditEntityFactory $editEntityFactory,
                                EntityNamespaceLookup $entityNamespaceLookup,
                                EntityTitleLookup $entityTitleLookup,
                                FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory,
                        Severity: Major
                        Found in repo/includes/Specials/SpecialNewItem.php - About 1 hr to fix

                          Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  ApiMain $mainModule,
                                  string $moduleName,
                                  LinkBatchFactory $linkBatchFactory,
                                  EntitySearchHelper $entitySearchHelper,
                                  ContentLanguages $termLanguages,
                          Severity: Major
                          Found in repo/includes/Api/SearchEntities.php - About 1 hr to fix

                            Method factory has 13 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    ApiMain $mainModule,
                                    string $moduleName,
                                    LinkBatchFactory $linkBatchFactory,
                                    ApiHelperFactory $apiHelperFactory,
                                    array $enabledEntityTypes,
                            Severity: Major
                            Found in repo/includes/Api/SearchEntities.php - About 1 hr to fix

                              Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      EntityExistenceChecker $entityExistenceChecker,
                                      EntityIdParser $entityIdParser,
                                      TermLookup $termLookup,
                                      EntityNamespaceLookup $localEntityNamespaceLookup,
                                      InterwikiLookup $interwikiLookup,
                              Severity: Major
                              Found in repo/includes/Hooks/HtmlPageLinkRendererEndHookHandler.php - About 1 hr to fix

                                Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        EntityTermStoreWriter $entityTermStoreWriter,
                                        EntityContentDataCodec $contentCodec,
                                        EntityConstraintProvider $constraintProvider,
                                        ValidatorErrorLocalizer $errorLocalizer,
                                        EntityIdParser $entityIdParser,
                                Severity: Major
                                Found in repo/includes/Content/ItemHandler.php - About 1 hr to fix

                                  Function save has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          save: function ( statement ) {
                                              var self = this,
                                                  deferred = $.Deferred();
                                  
                                              this._api.setClaim(
                                  Severity: Minor
                                  Found in view/resources/wikibase/entityChangers/StatementsChanger.js - About 1 hr to fix

                                    Function _setOption has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                            _setOption: function ( key, value ) {
                                                var response = PARENT.prototype._setOption.apply( this, arguments );
                                    
                                                if ( key === 'disabled' ) {
                                                    if ( this._mainSnakSnakView ) {
                                    Severity: Minor
                                    Found in view/resources/jquery/wikibase/jquery.wikibase.statementview.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language