wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function filterEntitySerializationUsingProps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function filterEntitySerializationUsingProps( array $serialization, $props ) {
        if ( $props !== 'all' ) {
            if ( !in_array( 'labels', $props ) ) {
                unset( $serialization['labels'] );
            }
Severity: Minor
Found in repo/includes/Api/ResultBuilder.php - 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

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

        ApiMain $mainModule,
        string $moduleName,
        IBufferingStatsdDataFactory $statsdDataFactory,
        EntityRevisionLookup $revisionLookup,
        EntityIdParser $idParser,
Severity: Major
Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

    Function onBeforePageDisplay has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
            $entityNamespaceLookup = WikibaseRepo::getEntityNamespaceLookup();
            $namespace = $out->getTitle()->getNamespace();
            $isEntityTitle = $entityNamespaceLookup->isNamespaceWithEntities( $namespace );
            $settings = WikibaseRepo::getSettings();
    Severity: Minor
    Found in repo/includes/RepoHooks.php - 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 validateEntitySpecificParameters has a Cognitive Complexity of 11 (exceeds 5 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

    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

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

            ApiMain $mainModule,
            string $moduleName,
            SiteLinkStore $siteLinkStore,
            SiteLinkGlobalIdentifiersProvider $siteLinkGlobalIdentifiersProvider,
            SiteLinkTargetProvider $siteLinkTargetProvider,
    Severity: Major
    Found in repo/includes/Api/LinkTitles.php - About 1 hr to fix

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

              ApiMain $mainModule,
              string $moduleName,
              ApiErrorReporter $errorReporter,
              StatementChangeOpFactory $statementChangeOpFactory,
              StatementModificationHelper $modificationHelper,
      Severity: Major
      Found in repo/includes/Api/RemoveReferences.php - About 1 hr to fix

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

                OutputPageEntityViewChecker $entityViewChecker,
                OutputPageJsConfigBuilder $outputPageJsConfigBuilder,
                ContentLanguages $termsLanguages,
                UserLanguageLookup $userLanguageLookup,
                UserPreferredContentLanguagesLookup $userPreferredContentLanguagesLookup,
        Severity: Major
        Found in repo/includes/Hooks/MakeGlobalVariablesScriptHookHandler.php - About 1 hr to fix

          Function addValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addValue(
                  RdfWriter $writer,
                  $propertyValueNamespace,
                  $propertyValueLName,
                  $dataType,
          Severity: Minor
          Found in repo/includes/Rdf/Values/QuantityRdfBuilder.php - 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 createEntityChangeOp has a Cognitive Complexity of 11 (exceeds 5 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 );

          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 fixEditConflict has a Cognitive Complexity of 11 (exceeds 5 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

          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 deserialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function deserialize( string $siteId, array $serialization, string $basePath = '' ): SiteLink {
                  if ( !array_key_exists( 'title', $serialization ) ) {
                      throw new MissingFieldException( 'title', $basePath );
                  }
          
          

          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 getCacheKeys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getCacheKeys( array $entityIds, array $termTypes, array $languageCodes ): array {
                  $cacheKeys = [];
                  $unresolvedIds = [];
                  $keyPartsMap = [];
                  foreach ( $entityIds as $entityId ) {
          Severity: Minor
          Found in lib/includes/Store/CachingPrefetchingTermLookup.php - 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 acquireTermInLangIds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function acquireTermInLangIds( array $termsArray, $callback = null ): array {
                  $ids = [];
          
                  foreach ( $termsArray as $type => $termsOfType ) {
                      foreach ( $termsOfType as $lang => $terms ) {
          Severity: Minor
          Found in lib/includes/Store/Sql/Terms/InMemoryTermStore.php - 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 updateQueryBuilder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function updateQueryBuilder( SelectQueryBuilder $queryBuilder, array $entityIds, IReadableDatabase $db ) {
                  $where = [];
                  $joinSlotsTable = false;
          
                  foreach ( $entityIds as $entityId ) {
          Severity: Minor
          Found in lib/includes/Store/Sql/PageTableEntityQueryBase.php - 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 getEntityRevisionFromCache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getEntityRevisionFromCache(
                  EntityId $entityId,
                  $revisionId = 0,
                  $mode = LookupConstants::LATEST_FROM_REPLICA
              ) {
          Severity: Minor
          Found in lib/includes/Store/CacheRetrievingEntityRevisionLookup.php - 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 trimStatementGroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private trimStatementGroup(
                  newStatements: readonly Statement[],
                  baseStatements: readonly Statement[],
              ): Statement[] | null {
                  const baseStatementsById = statementListById( baseStatements );
          Severity: Minor
          Found in client/data-bridge/src/data-access/TrimmingWritingRepository.ts - 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

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

                  EntityIdParser $entityIdParser,
                  EntityIdComposer $entityIdComposer,
                  Deserializer $dataValueDeserializer,
                  NameTableStoreFactory $nameTableStoreFactory,
                  DataAccessSettings $dataAccessSettings,
          Severity: Major
          Found in data-access/src/SingleEntitySourceServicesFactory.php - About 1 hr to fix

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

                    _create: function () {
                        var self = this,
                            $dialogSpinner = $.createSpinner();
            
                        this.element
            Severity: Minor
            Found in client/resources/jquery.wikibase/jquery.wikibase.linkitem.js - About 1 hr to fix

              Function attachWatchLinkUpdater has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function attachWatchLinkUpdater( $entityview, viewName ) {
                      var update;
              
                      if ( mw.loader.getState( 'mediawiki.page.watch.ajax' ) !== 'ready' || !mw.user.options.get( 'watchdefault' ) ) {
                          return;
              Severity: Minor
              Found in repo/resources/wikibase.ui.entityViewInit.js - About 1 hr to fix

                Function setSiteLink has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        setSiteLink: function ( siteLink, tempUserWatcher ) {
                            var self = this,
                                deferred = $.Deferred();
                
                            this._api.setSitelink(
                Severity: Minor
                Found in view/resources/wikibase/entityChangers/SiteLinksChanger.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language