wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function loadEntity has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadEntity( array $requestParams, ?EntityId $entityId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
        if ( !in_array( $assignFreshId, [ self::ASSIGN_FRESH_ID, self::NO_FRESH_ID ] ) ) {
            throw new InvalidArgumentException(
                '$assignFreshId must be either of the EntitySavingHelper::ASSIGN_FRESH_ID/NO_FRESH_ID constants.'
            );
Severity: Minor
Found in repo/includes/Api/EntitySavingHelper.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 resolveTermInLangIds has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveTermInLangIds(
        array $termInLangIds,
        array $types = null,
        array $languages = null
    ): array {
Severity: Minor
Found in lib/includes/Store/Sql/Terms/InMemoryTermStore.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 getLocalizedYear has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function getLocalizedYear( $isoTimestamp, $precision ) {
        preg_match( '/^(\D*)(\d*)/', $isoTimestamp, $matches );
        [ , $sign, $year ] = $matches;
        $isBCE = $sign === '-';

Severity: Minor
Found in lib/includes/Formatters/MwTimeIsoFormatter.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 getFormatter has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getFormatter( $dataValueType, $dataTypeId = null ): ValueFormatter {
        $formatter = null;

        if ( $dataTypeId !== null ) {
            if ( isset( $this->formatters["PT:$dataTypeId"] ) ) {
Severity: Minor
Found in lib/includes/Formatters/DispatchingValueFormatter.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 modifyUsingUnflattenedCallbacks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function modifyUsingUnflattenedCallbacks( &$value, array $modifications ): void {
        $rootModifications = $modifications[''] ?? [];
        unset( $modifications[''] );

        if ( is_array( $value ) ) {
Severity: Minor
Found in lib/includes/Serialization/SerializationModifier.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

File OutputPageBeforeHTMLHookHandler.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Hooks;
Severity: Minor
Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php - About 2 hrs to fix

    Function show has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            show: function() {
                var title = this.getTitle();
                if (title && this.enabled) {
                    var $tip = this.tip();
    
    
    Severity: Major
    Found in client/resources/jquery.wikibase/jquery.tipsy/jquery.tipsy.js - About 2 hrs to fix

      Function show has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              show: function() {
                  var title = this.getTitle();
                  if (title && this.enabled) {
                      var $tip = this.tip();
      
      
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.tipsy/jquery.tipsy.js - About 2 hrs to fix

        Method getDefaultTermsLanguages has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getDefaultTermsLanguages( LanguageNameUtils $languageNameUtils = null ) {
                // Note: this list is also the basis of getDefaultMonolingualTextLanguages(); custom
                // (non-MediaWikiContentLanguages) terms languages also become monolingual text languages.
                return new UnionContentLanguages(
                    new MediaWikiContentLanguages( $languageNameUtils ),
        Severity: Major
        Found in lib/includes/WikibaseContentLanguages.php - About 2 hrs to fix

          Function initBridge has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public initBridge(
                  information: AppInformation,
              ): Promise<void> {
                  this.commit( 'setEditFlow', information.editFlow );
                  this.commit( 'setPropertyPointer', information.propertyId );
          Severity: Major
          Found in client/data-bridge/src/store/actions.ts - About 2 hrs to fix

            CachingPrefetchingTermLookup has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            final class CachingPrefetchingTermLookup implements PrefetchingTermLookup {
            
                use TermCacheKeyBuilder;
            
                private const DEFAULT_TTL = 60;
            Severity: Minor
            Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 2 hrs to fix

              Function _attachInputEventHandlers has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _attachInputEventHandlers: function () {
                          var self = this,
                              suppressKeyPress = false;
              
                          this.element
              Severity: Major
              Found in client/resources/jquery.ui/jquery.ui.suggester.js - About 2 hrs to fix

                File ModifyEntity.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare( strict_types = 1 );
                
                namespace Wikibase\Repo\Api;
                Severity: Minor
                Found in repo/includes/Api/ModifyEntity.php - About 2 hrs to fix

                  File RdfVocabulary.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace Wikibase\Repo\Rdf;
                  
                  use DataValues\DataValue;
                  Severity: Minor
                  Found in repo/includes/Rdf/RdfVocabulary.php - About 2 hrs to fix

                    Method assertValidStatements has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function assertValidStatements(
                            array $statementsSerialization,
                            Property $originalProperty,
                            array $originalStatementsSerialization
                        ): void {

                      Method showUndoForm has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function showUndoForm(): void {
                              $this->getOutput()->enableOOUI();
                              $req = $this->getRequest();
                      
                              if ( $this->showPermissionError( 'read' ) || $this->showPermissionError( 'edit' ) ) {
                      Severity: Major
                      Found in repo/includes/Actions/EditEntityAction.php - About 2 hrs to fix

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

                            public function execute() {
                                if ( !WikibaseSettings::isRepoEnabled() ) {
                                    $this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!" );
                                }
                                $format = $this->getOption( 'format', 'json' );
                        Severity: Major
                        Found in repo/maintenance/updateUnits.php - About 2 hrs to fix

                          File ParseValue.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          declare( strict_types = 1 );
                          
                          namespace Wikibase\Repo\Api;
                          Severity: Minor
                          Found in repo/includes/Api/ParseValue.php - About 2 hrs to fix

                            File FormatSnakValue.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            declare( strict_types = 1 );
                            
                            namespace Wikibase\Repo\Api;
                            Severity: Minor
                            Found in repo/includes/Api/FormatSnakValue.php - About 2 hrs to fix

                              Function draw has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      draw: function () {
                                          var done = $.Deferred().resolve().promise();
                                          var self = this,
                                              languageCode = this.options.value.getLanguageCode(),
                                              descriptionText = this.options.value.getText();
                              Severity: Major
                              Found in view/resources/jquery/wikibase/jquery.wikibase.descriptionview.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language