wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Method doSearch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function doSearch( $query ) {
        $limit = (int)$this->getOption( 'limit', 5 );

        $results = $this->searchHelper->getRankedSearchResults(
            $query,
Severity: Minor
Found in repo/maintenance/searchEntities.php - About 1 hr to fix

    Method handleDescriptionValidationErrors has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function handleDescriptionValidationErrors( ValidationError $validationError ): void {
            $context = $validationError->getContext();
            switch ( $validationError->getCode() ) {
                case DescriptionsSyntaxValidator::CODE_DESCRIPTIONS_NOT_ASSOCIATIVE:
                    throw UseCaseError::newInvalidValue( '/item/descriptions' );

      Method handleLabelsValidationError has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function handleLabelsValidationError( ValidationError $validationError ): void {
              $context = $validationError->getContext();
      
              switch ( $validationError->getCode() ) {
                  case LabelsSyntaxValidator::CODE_LABELS_NOT_ASSOCIATIVE:

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

            public function execute( PatchItemDescriptionsRequest $request ): PatchItemDescriptionsResponse {
                $deserializedRequest = $this->requestValidator->validateAndDeserialize( $request );
                $itemId = $deserializedRequest->getItemId();
        
                $this->assertItemExists->execute( $itemId );

          Method handleSitelinksValidationErrors has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function handleSitelinksValidationErrors( ValidationError $validationError, array $serialization ): void {
                  $context = $validationError->getContext();
                  $siteId = fn() => $context[SitelinkValidator::CONTEXT_SITE_ID];
          
                  switch ( $validationError->getCode() ) {

            Method makeNormalizer has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function makeNormalizer( PropertyId $propertyId, string $valueType ): DataValueNormalizer {
                    $dataTypeNormalizers = [];
                    $valueTypeNormalizers = [];
            
                    try {
            Severity: Minor
            Found in lib/includes/Normalization/SnakNormalizer.php - About 1 hr to fix

              Method factory has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function factory( $language, $sourceLanguage = null ) {
                      if ( is_string( $language ) ) {
                          $languageCode = self::validateLanguageCode( $language );
                      } else {
                          $languageCode = $language->getCode();
              Severity: Minor
              Found in lib/includes/LanguageWithConversion.php - About 1 hr to fix

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

                    function getRankName( rank ) {
                        for ( var rankName in datamodel.Statement.RANK ) {
                            if ( rank === datamodel.Statement.RANK[ rankName ] ) {
                                return rankName.toLowerCase();
                            }
                view/resources/jquery/wikibase/jquery.wikibase.statementview.js on lines 217..225

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

                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

                        _getRankName: function ( rank ) {
                            for ( var rankName in datamodel.Statement.RANK ) {
                                if ( rank === datamodel.Statement.RANK[ rankName ] ) {
                                    return rankName.toLowerCase();
                                }
                view/resources/jquery/wikibase/jquery.wikibase.statementview.RankSelector.js on lines 24..32

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

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

                        _createEntitytermsforlanguagelistviewToggler: function () {
                            this._registerTogglerForLanguagelistviewDiv( TOGGLER_OPTION_KEY );
                
                            this.$entitytermsforlanguagelistviewContainer.before(
                                this.$entitytermsforlanguagelistviewToggler
                Severity: Minor
                Found in view/resources/jquery/wikibase/jquery.wikibase.entitytermsview.js - About 1 hr to fix

                  Function e260 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  /***/ (function(module, exports, __webpack_require__) {
                  
                  "use strict";
                  
                  var toIndexedObject = __webpack_require__("fc6a");
                  Severity: Minor
                  Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

                    Method getChangeParamsForDiffOp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function getChangeParamsForDiffOp( DiffOp $diffOp, $siteId, $messagePrefix ) {
                            $params = [];
                    
                            if ( $diffOp instanceof DiffOpAdd ) {
                                $params['message'] = $messagePrefix . 'add';
                    Severity: Minor
                    Found in client/includes/RecentChanges/SiteLinkCommentCreator.php - About 1 hr to fix

                      Method showForm has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function showForm() {
                              $dataTypeSelect = new DataTypeSelector(
                                  $this->dataTypeFactory->getTypes(),
                                  $this->getLanguage()->getCode()
                              );
                      Severity: Minor
                      Found in repo/includes/Specials/SpecialListProperties.php - About 1 hr to fix

                        Method getChangeOp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function getChangeOp( array $preparedParameters, EntityDocument $entity ): ChangeOp {
                                if ( $this->shouldRemove( $preparedParameters ) ) {
                                    $linksite = $this->stringNormalizer->trimToNFC( $preparedParameters['linksite'] );
                                    return $this->siteLinkChangeOpFactory->newRemoveSiteLinkOp( $linksite );
                                } else {
                        Severity: Minor
                        Found in repo/includes/Api/SetSiteLink.php - About 1 hr to fix

                          Method modifyEntity has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
                                  if ( !( $entity instanceof Item ) ) {
                                      $this->errorReporter->dieError( "The given entity is not an item", "not-item" );
                                  }
                          
                          
                          Severity: Minor
                          Found in repo/includes/Api/SetSiteLink.php - About 1 hr to fix

                            Method getSecondaryDataUpdates has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function getSecondaryDataUpdates(
                                    Title $title,
                                    Content $content,
                                    $role,
                                    SlotRenderingProvider $slotOutput
                            Severity: Minor
                            Found in repo/includes/Content/ItemHandler.php - About 1 hr to fix

                              Method getRegexpsFromMessageText has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function getRegexpsFromMessageText( string $msgText ): array {
                                      static $pluralRegex = null;
                                      if ( $pluralRegex === null ) {
                                          // We need to match on a preg_quoted string here, so double quote
                                          $pluralRegex = '@' . preg_quote( preg_quote( '{{PLURAL:$1|' ) ) .
                              Severity: Minor
                              Found in repo/includes/Parsers/MwTimeIsoParser.php - About 1 hr to fix

                                Method getTimeParsers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function getTimeParsers() {
                                        global $wgDefaultUserOptions;
                                
                                        $eraParser = new MwEraParser( $this->options );
                                        $isoTimestampParser = new IsoTimestampParser(
                                Severity: Minor
                                Found in repo/includes/Parsers/TimeParserFactory.php - About 1 hr to fix

                                  Method handleLabelsValidationError has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private function handleLabelsValidationError( ValidationError $validationError ): void {
                                          $context = $validationError->getContext();
                                  
                                          switch ( $validationError->getCode() ) {
                                              case LabelsSyntaxValidator::CODE_LABELS_NOT_ASSOCIATIVE:

                                    Method formatSnak has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function formatSnak( Snak $snak ) {
                                            $warningText = '';
                                            try {
                                                return $this->snakFormatter->formatSnak( $snak );
                                            } catch ( MismatchingDataValueTypeException $ex ) {
                                    Severity: Minor
                                    Found in lib/includes/Formatters/ErrorHandlingSnakFormatter.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language