wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Method validateLabelText has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validateLabelText( string $labelText, string $language ): ?ValidationError {
        $result = $this->termValidatorFactory
            ->getLabelValidator( Property::ENTITY_TYPE )
            ->validate( $labelText );
        if ( !$result->isValid() ) {

    Method validateDescriptionText has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function validateDescriptionText( string $descriptionText, string $language ): ?ValidationError {
            $result = $this->termValidatorFactory
                ->getDescriptionValidator()
                ->validate( $descriptionText );
            if ( !$result->isValid() ) {

      Method fixEditConflict has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function fixEditConflict( EntityDocument $newEntity ): ?EntityDocument {
              $baseRev = $this->getBaseRevision();
              $latestRev = $this->getLatestRevision();
      
              if ( !$latestRev ) {
      Severity: Minor
      Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 1 hr to fix

        Method buildClaimSummary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function buildClaimSummary( ?Statement $oldStatement, Statement $newStatement ) {
                $summary = new Summary( $this->apiModuleName );
                // Only one statement touched, so we're always having singular here.
                $summary->addAutoCommentArgs( 1 );
                $summary->addAutoSummaryArgs( [
        Severity: Minor
        Found in repo/includes/ClaimSummaryBuilder.php - About 1 hr to fix

          Method validateAndDeserializeStatement has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function validateAndDeserializeStatement( $patchedStatement ): Statement {
                  if (
                      !is_array( $patchedStatement ) || ( count( $patchedStatement ) && array_is_list( $patchedStatement ) ) ) {
                      throw UseCaseError::newPatchResultInvalidValue( '', $patchedStatement );
                  }

            Method handleStatementsValidationErrors has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function handleStatementsValidationErrors( ValidationError $validationError ): void {
                    $context = $validationError->getContext();
                    switch ( $validationError->getCode() ) {
                        case StatementsValidator::CODE_STATEMENTS_NOT_ASSOCIATIVE:
                        case StatementsValidator::CODE_STATEMENT_GROUP_NOT_SEQUENTIAL:

              Method newStatementGroupListView has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function newStatementGroupListView(
                      $languageCode,
                      TermLanguageFallbackChain $termFallbackChain,
                      EditSectionGenerator $editSectionGenerator
                  ) {
              Severity: Minor
              Found in view/src/ViewFactory.php - About 1 hr to fix

                Method validateLabelText has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function validateLabelText( string $labelText, string $language ): ?ValidationError {
                        $result = $this->termValidatorFactory
                            ->getLabelValidator( Item::ENTITY_TYPE )
                            ->validate( $labelText );
                        if ( !$result->isValid() ) {

                  Method newSuccessHttpResponse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function newSuccessHttpResponse( CreateItemResponse $useCaseResponse ): Response {
                          $response = $this->getResponseFactory()->create();
                          $response->setStatus( 201 );
                          $response->setHeader( 'Content-Type', 'application/json' );
                          $response->setHeader(
                  Severity: Minor
                  Found in repo/rest-api/src/RouteHandlers/CreateItemRouteHandler.php - About 1 hr to fix

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

                        public function validateAndDeserialize( SitelinkEditRequest $request ): SiteLink {
                            $validationError = $this->validator->validate( $request->getItemId(), $request->getSiteId(), $request->getSitelink(), '/sitelink' );
                    
                            if ( $validationError ) {
                                $context = $validationError->getContext();

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

                          public function execute( AddPropertyAliasesInLanguageRequest $request ): AddPropertyAliasesInLanguageResponse {
                              $deserializedRequest = $this->validator->validateAndDeserialize( $request );
                      
                              $propertyId = $deserializedRequest->getPropertyId();
                              $languageCode = $deserializedRequest->getLanguageCode();

                        Method handleLabelValidationErrors has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function handleLabelValidationErrors( ValidationError $validationError ): void {
                                $context = $validationError->getContext();
                                switch ( $validationError->getCode() ) {
                                    case LabelsSyntaxValidator::CODE_LABELS_NOT_ASSOCIATIVE:
                                        throw UseCaseError::newInvalidValue( '/item/labels' );

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

                              public function execute( AddItemAliasesInLanguageRequest $request ): AddItemAliasesInLanguageResponse {
                                  $deserializedRequest = $this->validator->validateAndDeserialize( $request );
                          
                                  $itemId = $deserializedRequest->getItemId();
                                  $languageCode = $deserializedRequest->getLanguageCode();

                            Method addLanguageAndVariantsToChain has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function addLanguageAndVariantsToChain( $language, array &$chain, array &$fetched ): void {
                                    $languageCode = is_string( $language ) ? $language : $language->getCode();
                            
                                    $this->addLanguageToChain( $language, $chain, $fetched );
                            
                            
                            Severity: Minor
                            Found in lib/includes/LanguageFallbackChainFactory.php - About 1 hr to fix

                              Method newGlobeCoordinateFormatter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function newGlobeCoordinateFormatter( $format, FormatterOptions $options ) {
                                      $isHtmlVerboseFormat = $this->snakFormat->isPossibleFormat( SnakFormatter::FORMAT_HTML_VERBOSE, $format );
                              
                                      if ( $isHtmlVerboseFormat && $this->kartographerEmbeddingHandler ) {
                                          $isPreview = $format === SnakFormatter::FORMAT_HTML_VERBOSE_PREVIEW;
                              Severity: Minor
                              Found in lib/includes/Formatters/WikibaseValueFormatterBuilders.php - About 1 hr to fix

                                Method mapToTextInLangIds has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function mapToTextInLangIds(
                                        array $termsArray,
                                        ReplicaPrimaryAwareRecordIdsAcquirer $textInLangIdsAcquirer
                                    ) {
                                        $flattenedLangTextIds = [];
                                Severity: Minor
                                Found in lib/includes/Store/Sql/Terms/DatabaseTermInLangIdsAcquirer.php - About 1 hr to fix

                                  Method buildFromBabel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function buildFromBabel( array $babel ) {
                                          $chain = [];
                                          $fetched = [];
                                  
                                          // validate all the language codes and discard invalid ones
                                  Severity: Minor
                                  Found in lib/includes/LanguageFallbackChainFactory.php - About 1 hr to fix

                                    Method getMatchingTermIndexEntries has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private function getMatchingTermIndexEntries(
                                            $text,
                                            $languageCode,
                                            $entityType,
                                            array $termTypes
                                    Severity: Minor
                                    Found in lib/includes/Interactors/MatchingTermsLookupSearchInteractor.php - About 1 hr to fix

                                      Method getReferencedEntityId has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function getReferencedEntityId( EntityId $fromId, PropertyId $propertyId, array $toIds ) {
                                              if ( !$toIds ) {
                                                  return null;
                                              }
                                      
                                      

                                        Method decode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            private function decode( string $string, array $loggingContext ): ?array {
                                                $result = json_decode( $string );
                                        
                                                if ( !is_array( $result ) || count( $result ) !== 3 ) {
                                                    $this->logger->alert( 'Unknown or invalid cache format', $loggingContext + [
                                        Severity: Minor
                                        Found in lib/includes/SimpleCacheWithBagOStuff.php - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language