wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Method createOrUpdate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function createOrUpdate(
        EntityDocument $entity,
        EditMetadata $editMetadata,
        int $newOrUpdateFlag
    ): EntityRevision {
Severity: Minor
Found in repo/rest-api/src/Infrastructure/DataAccess/EntityUpdater.php - About 1 hr to fix

    Method validateAndDeserialize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function validateAndDeserialize( ItemLabelEditRequest $request ): Term {
            $item = $this->itemRetriever->getItemWriteModel( new ItemId( $request->getItemId() ) );
            $language = $request->getLanguageCode();
            $label = $request->getLabel();
    
    

      Method insertNonExistingRecords has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function insertNonExistingRecords(
              array $records,
              ?callable $recordsToInsertDecoratorCallback = null
          ): array {
              if ( !$records ) {

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

            public function runUseCase( string $propertyId ): Response {
                $jsonBody = $this->getValidatedBody();
                '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
                try {
                    return $this->newSuccessHttpResponse(
        repo/rest-api/src/RouteHandlers/PatchPropertyDescriptionsRouteHandler.php on lines 83..102
        repo/rest-api/src/RouteHandlers/PatchPropertyLabelsRouteHandler.php on lines 83..103
        repo/rest-api/src/RouteHandlers/PatchPropertyRouteHandler.php on lines 92..112

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

        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

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

            public function runUseCase( string $propertyId ): Response {
                $jsonBody = $this->getValidatedBody();
                '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
                try {
                    return $this->newSuccessHttpResponse(
        repo/rest-api/src/RouteHandlers/PatchPropertyAliasesRouteHandler.php on lines 84..101
        repo/rest-api/src/RouteHandlers/PatchPropertyLabelsRouteHandler.php on lines 83..103
        repo/rest-api/src/RouteHandlers/PatchPropertyRouteHandler.php on lines 92..112

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

        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

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

            public function runUseCase( string $propertyId ): Response {
                $jsonBody = $this->getValidatedBody();
                '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
        
                try {
        repo/rest-api/src/RouteHandlers/PatchPropertyAliasesRouteHandler.php on lines 84..101
        repo/rest-api/src/RouteHandlers/PatchPropertyDescriptionsRouteHandler.php on lines 83..102
        repo/rest-api/src/RouteHandlers/PatchPropertyLabelsRouteHandler.php on lines 83..103

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

        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

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

            public function runUseCase( string $propertyId ): Response {
                $jsonBody = $this->getValidatedBody();
                '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
        
                try {
        repo/rest-api/src/RouteHandlers/PatchPropertyAliasesRouteHandler.php on lines 84..101
        repo/rest-api/src/RouteHandlers/PatchPropertyDescriptionsRouteHandler.php on lines 83..102
        repo/rest-api/src/RouteHandlers/PatchPropertyRouteHandler.php on lines 92..112

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

        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 getLabelByLanguage( string $prefixedEntityId, string $languageCode ) {
                if ( !$this->termsLanguages->hasLanguage( $languageCode ) ) {
                    // Directly abort: Only track label usages for valid languages
                    return null;
                }
        client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php on lines 242..263

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

        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 getDescriptionByLanguage( string $prefixedEntityId, string $languageCode ) {
                if ( !$this->termsLanguages->hasLanguage( $languageCode ) ) {
                    // Directly abort: Only track description usages for valid languages
                    return null;
                }
        client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php on lines 214..234

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

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

        function makeLocalContext (store, namespace, path) {
          var noNamespace = namespace === '';
        
          var local = {
            dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
        Severity: Minor
        Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

          Method visualizeClaimChange has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function visualizeClaimChange(
                  ClaimDifference $claimDifference,
                  Statement $baseStatement,
                  array $path = []
              ) {
          Severity: Minor
          Found in repo/includes/Diff/ClaimDifferenceVisualizer.php - About 1 hr to fix

            Method getEntitySerializationWithMetaData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getEntitySerializationWithMetaData( array $serialization ) {
                    $serializeEmptyListsAsObjects = WikibaseRepo::getSettings()->getSetting( 'tmpSerializeEmptyListsAsObjects' );
                    $modifications = [];
            
                    $makeIdKvpCallback = $this->callbackFactory->getCallbackToSetArrayType( 'kvp', 'id' );
            Severity: Minor
            Found in repo/includes/Api/ResultBuilder.php - About 1 hr to fix

              Method getAllowedParams has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function getAllowedParams(): array {
                      return [
                          'search' => [
                              ParamValidator::PARAM_TYPE => 'string',
                              ParamValidator::PARAM_REQUIRED => true,
              Severity: Minor
              Found in repo/includes/Api/SearchEntities.php - About 1 hr to fix

                Method addSiteLinks has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function addSiteLinks( Item $item ) {
                        $id = $item->getId();
                        $entityLName = $this->vocabulary->getEntityLName( $id );
                        $entityRepoName = $this->vocabulary->getEntityRepositoryName( $id );
                
                
                Severity: Minor
                Found in repo/includes/Rdf/SiteLinksRdfBuilder.php - About 1 hr to fix

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

                      public function execute() {
                          if ( !WikibaseSettings::isRepoEnabled() ) {
                              $this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!\n" );
                          }
                  
                  
                  Severity: Minor
                  Found in repo/maintenance/removeTermsInLanguage.php - About 1 hr to fix

                    Method validateAndDeserialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function validateAndDeserialize( ItemDescriptionEditRequest $request ): Term {
                            $item = $this->itemRetriever->getItemWriteModel( new ItemId( $request->getItemId() ) );
                            $language = $request->getLanguageCode();
                            $description = $request->getDescription();
                    
                    

                      Method validateModifiedStatements has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function validateModifiedStatements(
                              array $originalSerialization,
                              StatementList $originalStatements,
                              array $serialization,
                              string $basePath = ''
                      Severity: Minor
                      Found in repo/rest-api/src/Application/Validation/StatementsValidator.php - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if ( !isset( $matches['year'] )
                                    || ( isset( $matches['day'] ) && !isset( $matches['month'] ) )
                                    || ( isset( $matches['hour'] ) && !isset( $matches['day'] ) )
                                    || ( isset( $matches['minute'] ) && !isset( $matches['hour'] ) )
                                    || ( isset( $matches['second'] ) && !isset( $matches['minute'] ) )
                        Severity: Critical
                        Found in repo/includes/Parsers/DateFormatParser.php - About 1 hr to fix

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

                                  if ( $formData[self::FIELD_DESCRIPTION] != '' ) {
                                      $validator = $this->termValidatorFactory->getDescriptionValidator();
                                      $result = $validator->validate( $formData[self::FIELD_DESCRIPTION] );
                                      $status->merge( $this->errorLocalizer->getResultStatus( $result ) );
                          
                          
                          Severity: Major
                          Found in repo/includes/Specials/SpecialNewItem.php and 1 other location - About 1 hr to fix
                          repo/includes/Specials/SpecialNewProperty.php on lines 272..280

                          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

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

                                  if ( $formData[self::FIELD_DESCRIPTION] != '' ) {
                                      $validator = $this->termValidatorFactory->getDescriptionValidator();
                                      $result = $validator->validate( $formData[self::FIELD_DESCRIPTION] );
                                      $status->merge( $this->errorLocalizer->getResultStatus( $result ) );
                          
                          
                          Severity: Major
                          Found in repo/includes/Specials/SpecialNewProperty.php and 1 other location - About 1 hr to fix
                          repo/includes/Specials/SpecialNewItem.php on lines 357..365

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language