wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function _setOption has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _setOption: function ( key, value ) {
            if ( key === 'value' ) {
                if ( value !== null
                    && !$.isPlainObject( value )
                    && !( value instanceof datamodel.Snak )
Severity: Minor
Found in view/resources/jquery/wikibase/snakview/snakview.js - About 1 hr to fix

    Function _onMulPulsatingDotClicked has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _onMulPulsatingDotClicked: function ( _event ) {
                if ( !this._popup ) {
                    var $target = $( this.element ).find( '.mw-pulsating-dot-popup-container' );
    
                    var dontShowMulPopupCheckbox = new OO.ui.CheckboxInputWidget( {

      Function _create has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _create: function () {
                  var self = this;
      
                  this._cache = {};
      
      
      Severity: Minor
      Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 1 hr to fix

        Method register has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function register() {
                // These functions will be exposed to the Lua module.
                // They are member functions on a Lua table which is private to the module, thus
                // these can't be called from user code, unless explicitly exposed in Lua.
                $lib = [
        Severity: Minor
        Found in client/includes/DataAccess/Scribunto/WikibaseLibrary.php - About 1 hr to fix

          Function 23e7 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          /***/ (function(module, exports, __webpack_require__) {
          
          var global = __webpack_require__("da84");
          var getOwnPropertyDescriptor = __webpack_require__("06cf").f;
          var createNonEnumerableProperty = __webpack_require__("9112");
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

            Method buildTermSearchMatchPageEntry has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function buildTermSearchMatchPageEntry( TermSearchResult $match, ?array $props ): array {
                    $entityId = $match->getEntityId();
                    if ( $entityId !== null ) {
                        $entry = [
                            'id' => $entityId->getSerialization(),
            Severity: Minor
            Found in repo/includes/Api/SearchEntities.php - About 1 hr to fix

              Method validateEntitySpecificParameters has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function validateEntitySpecificParameters(
                      array $preparedParameters,
                      EntityDocument $entity,
                      int $baseRevId
                  ): void {
              Severity: Minor
              Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

                Method resolveMentionedEntities has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function resolveMentionedEntities(): void {
                        $hasRedirect = false;
                
                        $this->markStubEntityDataForPrefetching( $this->entitiesResolved );
                
                
                Severity: Minor
                Found in repo/includes/Rdf/RdfBuilder.php - About 1 hr to fix

                  Method createEntityChangeOp has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function createEntityChangeOp( array $changeRequest ) {
                          $this->assertArray( $changeRequest['sitelinks'], 'List of sitelinks must be an array' );
                  
                          $siteLinksChangeOps = new ChangeOps();
                          $sites = $this->siteLinkTargetProvider->getSiteList( $this->siteLinkGroups );

                    Method convertToFormattableSummary has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function convertToFormattableSummary( EditSummary $editSummary ): FormatableSummary {
                            switch ( true ) {
                                case $editSummary instanceof PatchPropertyEditSummary:
                                    return $this->wholeEntityEditSummaryConverter->newSummaryForPropertyPatch( $editSummary );
                    
                    
                    Severity: Minor
                    Found in repo/rest-api/src/Infrastructure/EditSummaryFormatter.php - About 1 hr to fix

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

                          public function execute() {
                              if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseRepository' ) ) {
                                  $this->fatalError(
                                      "You need to have Wikibase enabled in order to use this "
                                      . "maintenance script!\n\n",
                      Severity: Minor
                      Found in repo/maintenance/rebuildItemTerms.php - About 1 hr to fix

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

                            public function validate(
                                ?string $itemId,
                                string $siteId,
                                array $sitelink,
                                string $basePath = ''

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

                              public function execute() {
                                  if ( WikibaseRepo::getSettings()
                                       ->getSetting( 'enablePopulateWithRandomEntitiesAndTermsScript' ) !== true
                                  ) {
                                      $this->output(
                          Severity: Minor
                          Found in repo/maintenance/populateWithRandomEntitiesAndTerms.php - About 1 hr to fix

                            Method throwUseCaseError has 36 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] );

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

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

                                Method format has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function format( $value ) {
                                        if ( !( $value instanceof TimeValue ) ) {
                                            throw new InvalidArgumentException( 'Data value type mismatch. Expected a TimeValue.' );
                                        }
                                
                                
                                Severity: Minor
                                Found in lib/includes/Formatters/TimeDetailsFormatter.php - About 1 hr to fix

                                  Method toStandardUnits has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function toStandardUnits( UnboundedQuantityValue $value ) {
                                          $fromUnit = $value->getUnit();
                                  
                                          if ( $fromUnit === '1' ) {
                                              // Won't convert unitless values
                                  Severity: Minor
                                  Found in lib/includes/Units/UnitConverter.php - About 1 hr to fix

                                    Method saveLinksOfItem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function saveLinksOfItem( Item $item ): bool {
                                            //First check whether there's anything to update
                                            $newLinks = $item->getSiteLinkList()->toArray();
                                            $oldLinks = $this->getSiteLinksForItem( $item->getId() );
                                    
                                    
                                    Severity: Minor
                                    Found in lib/includes/Store/Sql/SiteLinkTable.php - About 1 hr to fix

                                      Function 3f4e has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      /***/ (function(module, __webpack_exports__, __webpack_require__) {
                                      
                                      "use strict";
                                      /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupDevtoolsPlugin", function() { return setupDevtoolsPlugin; });
                                      /* harmony import */ var _env__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("abc5");
                                      Severity: Minor
                                      Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Function termFallbackResolver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      wikibase.view.termFallbackResolver = ( function ( wb ) {
                                          'use strict';
                                      
                                          var SELF = {};
                                      
                                      
                                      Severity: Minor
                                      Found in view/resources/wikibase/view/termFallbackResolver.js - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language