wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function getTermsOfEntities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTermsOfEntities( array $entityIds, array $termTypes, string $languageCode ): array {
        $this->termBuffer->prefetchTerms( $entityIds, $termTypes, [ $languageCode ] );

        $terms = [];
        foreach ( $entityIds as $entityId ) {
Severity: Minor
Found in client/includes/Api/PageTerms.php - About 2 hrs 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 getTermsOfEntities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTermsOfEntities( array $entityIds, array $termTypes, string $languageCode ): array {
        $this->termBuffer->prefetchTerms( $entityIds, $termTypes, [ $languageCode ] );

        $terms = [];
        foreach ( $entityIds as $entityId ) {
Severity: Minor
Found in repo/includes/Api/EntityTerms.php - About 2 hrs 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 createOrUpdate has a Cognitive Complexity of 16 (exceeds 5 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 2 hrs 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 updateQuantityUnit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateQuantityUnit( EntityDocument $entity ) {
        $updateCounter = 0;

        if ( !$entity instanceof StatementListProvider ) {
            $this->errorReporter->reportMessage(
Severity: Minor
Found in repo/maintenance/EntityQuantityUnitRebuilder.php - About 2 hrs 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 saveEntity has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public saveEntity(
        entity: Entity,
        base?: EntityRevision,
        assertUser = true,
    ): Promise<EntityRevisionWithRedirect> {
Severity: Major
Found in client/data-bridge/src/data-access/ApiWritingRepository.ts - About 2 hrs to fix

    File SpecialNewProperty.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Wikibase\Repo\Specials;
    
    use MediaWiki\Output\OutputPage;
    Severity: Minor
    Found in repo/includes/Specials/SpecialNewProperty.php - About 2 hrs to fix

      Function _createListView has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _createListView: function () {
                  var self = this,
                      listItemAdapter = this.options.getListItemAdapter(
                          function () {
                              return self._getUnusedAllowedSiteIds().map( function ( siteId ) {
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.wikibase.sitelinklistview.js - About 2 hrs to fix

        Method switchForm has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function switchForm( $siteId, $page ) {
                $siteExists = $siteId
                    && $this->siteLinkTargetProvider->getSiteList( $this->groups )->hasSite( $siteId );
        
                $this->logger->debug(
        Severity: Major
        Found in repo/includes/Specials/SpecialItemByTitle.php - About 2 hrs to fix

          Method assertValidSitelinks has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function assertValidSitelinks( string $itemId, array $originalSitelinks, array $serialization ): void {
                  $validationError = $this->sitelinksValidator->validate(
                      $itemId,
                      $serialization,
                      $this->getModifiedSitelinksSites( $originalSitelinks, $serialization )

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

                public function getEntityRevision(
                    EntityId $entityId,
                    $revisionId = 0,
                    $mode = LookupConstants::LATEST_FROM_REPLICA
                ) {
            Severity: Major
            Found in lib/includes/Store/Sql/WikiPageEntityRevisionLookup.php - About 2 hrs to fix

              Function initLinkItem has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function initLinkItem( elem ) {
                      var $spinner = $.createSpinner(),
                          $linkItemLink = $( elem );
              
                      $linkItemLink
              Severity: Minor
              Found in client/resources/wikibase.client.linkitem.init.js - About 2 hrs to fix

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

                        _create: function () {
                            var self = this;
                
                            PARENT.prototype._create.call( this );
                
                

                  Function _createListView has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          _createListView: function () {
                              var self = this,
                                  listItemWidget = $.wikibase.entitytermsforlanguageview,
                                  prefix = listItemWidget.prototype.widgetEventPrefix;
                  
                  

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

                            _create: function () {
                                if ( !( this.options.value instanceof datamodel.Fingerprint )
                                    || !Array.isArray( this.options.userLanguages )
                                ) {
                                    throw new Error( 'Required option(s) missing' );
                    Severity: Minor
                    Found in view/resources/jquery/wikibase/jquery.wikibase.entitytermsview.js - About 2 hrs to fix

                      Method run has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function run(): bool {
                              $change = $this->getChange();
                              $titles = $this->getTitles();
                      
                              if ( !$change || $titles === [] ) {
                      Severity: Minor
                      Found in client/includes/Changes/InjectRCRecordsJob.php - About 2 hrs to fix

                        Method getStatus has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
                                if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
                                    $olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );
                        
                                    if ( !$olderRevision ) {
                        Severity: Minor
                        Found in repo/includes/Actions/EditEntityAction.php - About 2 hrs to fix

                          Method getFormFields has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function getFormFields() {
                                  $formFields = [
                                      self::FIELD_LANG => [
                                          'name' => self::FIELD_LANG,
                                          'class' => HTMLContentLanguageField::class,
                          Severity: Minor
                          Found in repo/includes/Specials/SpecialNewProperty.php - About 2 hrs to fix

                            Method __construct has 16 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    array $tags,
                                    SpecialPageCopyrightView $copyrightView,
                                    EntityNamespaceLookup $entityNamespaceLookup,
                                    SummaryFormatter $summaryFormatter,
                                    EntityTitleLookup $entityTitleLookup,
                            Severity: Major
                            Found in repo/includes/Specials/SpecialNewItem.php - About 2 hrs to fix

                              Method __construct has 16 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      EntityTitleStoreLookup $entityTitleStoreLookup,
                                      ExceptionLocalizer $exceptionLocalizer,
                                      PropertyDataTypeLookup $dataTypeLookup,
                                      SiteLookup $siteLookup,
                                      SummaryFormatter $summaryFormatter,
                              Severity: Major
                              Found in repo/includes/Api/ApiHelperFactory.php - About 2 hrs to fix

                                Method __construct has 16 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        HttpRequestFactory $httpRequestFactory,
                                        IBufferingStatsdDataFactory $statsdDataFactory,
                                        SettingsArray $repoSettings,
                                        TemplateFactory $templateFactory,
                                        EntityRevisionLookup $entityRevisionLookup,
                                Severity: Major
                                Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language