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

    private function renderLabelValuePair( $fieldName, $valueHtml ) {
        $html = Html::openElement( 'tr' );

        $html .= Html::element( 'th', [ 'class' => 'wb-quantity-' . $fieldName ],
            $this->getFieldLabel( $fieldName )->text() );
Severity: Major
Found in lib/includes/Formatters/QuantityDetailsFormatter.php and 1 other location - About 1 hr to fix
lib/includes/Formatters/GlobeCoordinateDetailsFormatter.php on lines 116..126

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

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 getParamSettings(): array {
        return [
            self::PROPERTY_ID_PATH_PARAM => [
                self::PARAM_SOURCE => 'path',
                ParamValidator::PARAM_TYPE => 'string',
Severity: Major
Found in repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php and 1 other location - About 1 hr to fix
repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php on lines 134..149

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

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

    SELF.prototype.getEntityTermsView = function ( startEditingCallback, value, $entitytermsview ) {
        var controller;
        var startEditingController = function () {
            return controller.startEditing();
        };
Severity: Minor
Found in view/resources/wikibase/view/ControllerViewFactory.js - About 1 hr to fix

    Function plot has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function plot( el, historyData ) {
        const traces = [];
        const annotations = [];
    
        for ( const fileName in historyData ) {
    Severity: Minor
    Found in build/dist-size/web/lib/main.js - About 1 hr to fix

      Function installModule has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function installModule (store, rootState, path, module, hot) {
        var isRoot = !path.length;
        var namespace = store._modules.getNamespace(path);
      
        // register in namespace map
      Severity: Minor
      Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

        Method getRankedSearchResults has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRankedSearchResults(
                $text,
                $languageCode,
                $entityType,
                $limit,
        Severity: Minor
        Found in repo/includes/FederatedProperties/ApiEntitySearchHelper.php - About 1 hr to fix

          Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run(): bool {
                  // TODO: for v2 of this job, we could actually get all the newest revision from the DB,
                  //       calculate the change_info ourselves and thus make wb_changes table obsolete?
          
                  $repoSettings = WikibaseRepo::getSettings();
          Severity: Minor
          Found in repo/includes/ChangeModification/DispatchChangesJob.php - About 1 hr to fix

            Method getMediaWikiPermissionsToCheck has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getMediaWikiPermissionsToCheck( $action, $entityType ) {
                    if ( $action === self::ACTION_MW_CREATE ) {
                        $entityTypeSpecificCreatePermission = $entityType . '-create';
            
                        $permissions = [ 'read', 'edit', 'createpage' ];
            Severity: Minor
            Found in repo/includes/Store/WikiPageEntityStorePermissionChecker.php - About 1 hr to fix

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

                Method validate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function validate( $value ): Result {
                        if ( !is_string( $value ) ) {
                            throw new InvalidArgumentException( 'Expected a string' );
                        }
                
                
                Severity: Minor
                Found in repo/includes/Validators/EntityUriValidator.php - About 1 hr to fix

                  Method createEntity has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function createEntity( $entityType, EntityId $customId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
                          if ( $customId ) {
                              $entityType = $customId->getEntityType();
                          } elseif ( !$entityType ) {
                              $this->errorReporter->dieError(
                  Severity: Minor
                  Found in repo/includes/Api/EntitySavingHelper.php - About 1 hr to fix

                    Method validateDataValue has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function validateDataValue( DataValue $dataValue, $dataTypeId ) {
                            try {
                                $dataValueType = $this->dataTypeFactory->getType( $dataTypeId )->getDataValueType();
                            } catch ( OutOfBoundsException $ex ) {
                                return Result::newError( [
                    Severity: Minor
                    Found in repo/includes/Validators/SnakValidator.php - About 1 hr to fix

                      Method initFormats has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function initFormats() {
                              if ( $this->mimeTypes !== null && $this->fileExtensions !== null ) {
                                  return;
                              }
                      
                      
                      Severity: Minor
                      Found in repo/includes/LinkedData/EntityDataFormatProvider.php - About 1 hr to fix

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

                            public function execute( PatchPropertyLabelsRequest $request ): PatchPropertyLabelsResponse {
                                $deserializedRequest = $this->useCaseValidator->validateAndDeserialize( $request );
                                $propertyId = $deserializedRequest->getPropertyId();
                        
                                $this->assertPropertyExists->execute( $propertyId );

                          Method throwUseCaseError has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function throwUseCaseError( ValidationError $validationError ): void {
                                  $context = $validationError->getContext();
                                  switch ( $validationError->getCode() ) {
                                      case LanguageCodeValidator::CODE_INVALID_LANGUAGE_CODE:
                                          throw UseCaseError::newPatchResultInvalidKey( '', $context[LanguageCodeValidator::CONTEXT_LANGUAGE_CODE] );

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

                                    function ( model, toolbar, view, removeView, startEditingCallback ) {
                                        this._model = model;
                                        this._toolbar = toolbar;
                                        this._view = view;
                                        this._removeView = removeView;
                            Severity: Major
                            Found in view/resources/wikibase/view/ToolbarViewController.js and 1 other location - About 1 hr to fix
                            repo/resources/formatters/ApiValueFormatter.js on lines 28..34

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

                            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

                                    function ( formatValueCaller, additionalOptions, dataTypeId, propertyId, outputType ) {
                                        this._formatValueCaller = formatValueCaller;
                                        this._options = additionalOptions;
                                        this._dataTypeId = dataTypeId;
                                        this._propertyId = propertyId;
                            Severity: Major
                            Found in repo/resources/formatters/ApiValueFormatter.js and 1 other location - About 1 hr to fix
                            view/resources/wikibase/view/ToolbarViewController.js on lines 29..35

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

                            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

                                private addStopEditingHook( store: Store<Application> ): void {
                                    this.mwHooks( 'wikibase.statement.stopEditing' ).add( ( guid: string ) => {
                                        store.dispatch( STOP_EDIT, guid );
                                    } );
                                }
                            Severity: Major
                            Found in view/lib/wikibase-tainted-ref/src/MWHookHandler.ts and 1 other location - About 1 hr to fix
                            view/lib/wikibase-tainted-ref/src/MWHookHandler.ts on lines 31..35

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

                            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

                                private addStartEditingHook( store: Store<Application> ): void {
                                    this.mwHooks( 'wikibase.statement.startEditing' ).add( ( guid: string ) => {
                                        store.dispatch( START_EDIT, guid );
                                    } );
                                }
                            Severity: Major
                            Found in view/lib/wikibase-tainted-ref/src/MWHookHandler.ts and 1 other location - About 1 hr to fix
                            view/lib/wikibase-tainted-ref/src/MWHookHandler.ts on lines 54..58

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

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

                                    updateVariation: function () {
                                        var value = this.value(),
                                            propertyId = value ? value.property : null,
                                            snakType = value ? value.snaktype : null,
                                            VariationConstructor = snakType ? variations.getVariation( snakType ) : null;
                            Severity: Minor
                            Found in view/resources/jquery/wikibase/snakview/snakview.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language