wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

    private function newSuccessHttpResponse( AddPropertyAliasesInLanguageResponse $useCaseResponse ): Response {
        $httpResponse = $this->getResponseFactory()->create();
        $httpResponse->setStatus( $useCaseResponse->wasAddedToExistingAliasGroup() ? 200 : 201 );
        $httpResponse->setHeader( 'Content-Type', 'application/json' );
        $httpResponse->setHeader(
repo/rest-api/src/RouteHandlers/AddItemAliasesInLanguageRouteHandler.php on lines 157..169

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

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 5 locations. Consider refactoring.
Open

    public function __construct(
        GuidGenerator $guidGenerator,
        StatementGuidValidator $guidValidator,
        StatementGuidParser $guidParser,
        SnakValidator $snakValidator,
Severity: Major
Found in repo/includes/ChangeOp/StatementChangeOpFactory.php and 4 other locations - About 2 hrs to fix
repo/includes/Interactors/EntityRedirectCreationInteractor.php on lines 45..63
repo/includes/Interactors/ItemMergeInteractor.php on lines 48..66
repo/rest-api/src/Application/UseCases/PatchStatement/PatchStatement.php on lines 34..52
repo/rest-api/src/Infrastructure/DataAccess/EntityUpdater.php on lines 44..62

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

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 5 locations. Consider refactoring.
Open

    public function __construct(
        EntityRevisionLookup $entityRevisionLookup,
        EntityStore $entityStore,
        EntityPermissionChecker $permissionChecker,
        SummaryFormatter $summaryFormatter,
repo/includes/ChangeOp/StatementChangeOpFactory.php on lines 59..77
repo/includes/Interactors/ItemMergeInteractor.php on lines 48..66
repo/rest-api/src/Application/UseCases/PatchStatement/PatchStatement.php on lines 34..52
repo/rest-api/src/Infrastructure/DataAccess/EntityUpdater.php on lines 44..62

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

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

File ParseValue.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Api;
Severity: Minor
Found in repo/includes/Api/ParseValue.php - About 2 hrs to fix

    File FormatSnakValue.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare( strict_types = 1 );
    
    namespace Wikibase\Repo\Api;
    Severity: Minor
    Found in repo/includes/Api/FormatSnakValue.php - About 2 hrs to fix

      Function draw has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              draw: function () {
                  var done = $.Deferred().resolve().promise();
                  var self = this,
                      languageCode = this.options.value.getLanguageCode(),
                      descriptionText = this.options.value.getText();
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.wikibase.descriptionview.js - About 2 hrs to fix

        Method assertValidStatements has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function assertValidStatements( array $serialization, Item $originalItem, array $originalStatementsSerialization ): void {
                $validationError = $this->statementsValidator->validateModifiedStatements(
                    $originalStatementsSerialization,
                    $originalItem->getStatements(),
                    $serialization['statements'] ?? [],

          File jquery.wikibase.badgeselector.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * @license GPL-2.0-or-later
           * @author H. Snater < mediawiki@snater.com >
           */
          ( function () {
          Severity: Minor
          Found in view/resources/jquery/wikibase/jquery.wikibase.badgeselector.js - About 2 hrs to fix

            RdfBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class RdfBuilder implements EntityRdfBuilder, EntityStubRdfBuilder, EntityMentionListener {
            
                /**
                 * A list of entities mentioned/touched to or by this builder.
                 * The prefixed entity IDs are used as keys in the array, the value 'true'
            Severity: Minor
            Found in repo/includes/Rdf/RdfBuilder.php - About 2 hrs to fix

              EntityContent has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              abstract class EntityContent extends AbstractContent {
              
                  /**
                   * Flag for use with EntityHandler::validateSave(), indicating that no pre-save validation should be applied.
                   * Can be passed in via EditEntity::attemptSave, EntityStore::saveEntity,
              Severity: Minor
              Found in repo/includes/Content/EntityContent.php - About 2 hrs to fix

                WikibaseValueFormatterBuilders has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class WikibaseValueFormatterBuilders {
                
                    /**
                     * @var FormatterLabelDescriptionLookupFactory
                     */
                Severity: Minor
                Found in lib/includes/Formatters/WikibaseValueFormatterBuilders.php - About 2 hrs to fix

                  StatementList has 23 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class StatementList implements IteratorAggregate, Countable {
                  
                      /**
                       * @var Statement[]
                       */
                  Severity: Minor
                  Found in lib/packages/wikibase/data-model/src/Statement/StatementList.php - About 2 hrs to fix

                    Fingerprint has 23 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Fingerprint implements LabelsProvider, DescriptionsProvider, AliasesProvider {
                    
                        /**
                         * @deprecated since 2.5, use new Fingerprint() instead.
                         *
                    Severity: Minor
                    Found in lib/packages/wikibase/data-model/src/Term/Fingerprint.php - About 2 hrs to fix

                      Method mergeChanges has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function mergeChanges( EntityId $entityId, array $changes ) {
                              if ( count( $changes ) === 1 ) {
                                  return reset( $changes );
                              }
                      
                      
                      Severity: Major
                      Found in client/includes/Changes/ChangeRunCoalescer.php - About 2 hrs to fix

                        Method getEntityRevision has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getEntityRevision( EntityId $id, $revision, $allowRedirects = false ) {
                                $prefixedId = $id->getSerialization();
                                $redirectRevision = null;
                        
                                try {
                        Severity: Major
                        Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 2 hrs to fix

                          Function draw has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  draw: function () {
                                      var self = this,
                                          deferred = $.Deferred(),
                                          languageCode = this.options.value.getLanguageCode(),
                                          labelText = this.options.value.getText();
                          Severity: Major
                          Found in view/resources/jquery/wikibase/jquery.wikibase.labelview.js - About 2 hrs to fix

                            Method internalDoHtmlPageLinkRendererEnd has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function internalDoHtmlPageLinkRendererEnd(
                                    LinkRenderer $linkRenderer,
                                    Title $target,
                                    &$text,
                                    array &$customAttribs,
                            Severity: Major
                            Found in repo/includes/Hooks/HtmlPageLinkRendererEndHookHandler.php - About 2 hrs to fix

                              Function createServices has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export default function createServices(
                                  mwWindow: MwWindow,
                                  editTags: readonly string[],
                                  eventTracker: Tracker,
                              ): ServiceContainer {
                              Severity: Major
                              Found in client/data-bridge/src/services/createServices.ts - About 2 hrs to fix

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

                                <?php
                                
                                declare( strict_types = 1 );
                                
                                namespace Wikibase\Repo\ParserOutput;
                                Severity: Major
                                Found in repo/includes/ParserOutput/ItemParserOutputUpdater.php and 1 other location - About 2 hrs to fix
                                repo/includes/ParserOutput/PropertyParserOutputUpdater.php on lines 1..37

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

                                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

                                <?php
                                
                                declare( strict_types = 1 );
                                
                                namespace Wikibase\Repo\ParserOutput;
                                Severity: Major
                                Found in repo/includes/ParserOutput/PropertyParserOutputUpdater.php and 1 other location - About 2 hrs to fix
                                repo/includes/ParserOutput/ItemParserOutputUpdater.php on lines 1..37

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

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language