wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function buildFromBabel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildFromBabel( array $babel ) {
        $chain = [];
        $fetched = [];

        // validate all the language codes and discard invalid ones
Severity: Minor
Found in lib/includes/LanguageFallbackChainFactory.php - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        EntityId $fromId,
        PropertyId $propertyId,
        array $toIds,
        $maxDepth,
        $message = null,

    Function validateBridgeApplicability has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public validateBridgeApplicability(
            path: MainSnakPath,
        ): Promise<unknown> {
            if ( this.state.applicationStatus === ApplicationStatus.SAVED ) {
                // saving edits can transition us from applicable to inapplicable states, but that should not be an error
    Severity: Minor
    Found in client/data-bridge/src/store/actions.ts - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            EntityId $fromId,
            PropertyId $propertyId,
            array $toIds,
            $maxEntityVisits,
            $message = null,

      Function newDefinitionsFromConfigArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function newDefinitionsFromConfigArray( array $sourceConfig, SubEntityTypesMapper $subEntityTypesMapper ) {
              $this->assertConfigArrayWellFormed( $sourceConfig );
      
              $sources = [];
      
      
      Severity: Minor
      Found in data-access/src/EntitySourceDefinitionsConfigParser.php - About 45 mins 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 getEntitySourceById has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getEntitySourceById( EntityId $id ): EntitySource {
              foreach ( $this->entitySourceDefinitions->getSources() as $source ) {
                  if (
                      strpos( $id->getSerialization(), $source->getConceptBaseUri() ) === 0 &&
                      $source->getType() === ApiEntitySource::TYPE
      Severity: Minor
      Found in data-access/src/EntitySourceLookup.php - About 45 mins 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 patchAliasGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function patchAliasGroup( AliasGroupList $groups, $lang, DiffOp $diffOp ) {
              $hasLang = $groups->hasGroupForLanguage( $lang );
      
              switch ( true ) {
                  case $diffOp instanceof DiffOpAdd:

      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 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $name,
              array $entityTypes,
              $conceptBaseUri,
              $rdfNodeNamespacePrefix,
              $rdfPredicateNamespacePrefix,
      Severity: Minor
      Found in data-access/src/ApiEntitySource.php - About 45 mins to fix

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

                EntityIdParser $propertyIdParser,
                Deserializer $dataValueDeserializer,
                PropertyDataTypeLookup $dataTypeLookup,
                array $deserializerBuilders,
                array $dataTypeToValueTypeMap,

          Function getApiQueryResponsePage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export function getApiQueryResponsePage( response: ApiQueryResponseBody, title: string ): ApiQueryResponsePage|null {
              for ( const normalized of ( response.normalized || [] ) ) {
                  if ( normalized.from === title ) {
                      title = normalized.to;
                      break;
          Severity: Minor
          Found in client/data-bridge/src/data-access/ApiQuery.ts - About 45 mins 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 addReference has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addReference( Reference $reference, $index = null ) {
                  if ( $index !== null && ( !is_int( $index ) || $index < 0 ) ) {
                      throw new InvalidArgumentException( '$index must be a non-negative integer or null' );
                  }
          
          
          Severity: Minor
          Found in lib/packages/wikibase/data-model/src/ReferenceList.php - About 45 mins 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

          Consider simplifying this complex logical expression.
          Open

                  if (
                      !editEntityResponse.entity ||
                      !editEntityResponse.entity.id ||
                      !editEntityResponse.entity.labels ||
                      !editEntityResponse.entity.descriptions ||
          Severity: Major
          Found in view/resources/wikibase/termbox/RepoApiWritingEntityRepository.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                    if ( ( $year == 0 && $precision < TimeValue::PRECISION_YEAR )
                        || ( $month == 0 && $precision >= TimeValue::PRECISION_MONTH )
                        || ( $day == 0 && $precision >= TimeValue::PRECISION_DAY )
                    ) {
                        throw new InvalidArgumentException( 'Time value insufficient for precision.' );
            Severity: Major
            Found in lib/includes/Formatters/MwTimeIsoFormatter.php - About 40 mins to fix

              Function PageConnector has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      repoApi,
                      firstSiteId,
                      firstPageName,
                      secondSiteId,
                      secondPageName
              Severity: Minor
              Found in client/resources/wikibase.client.PageConnector.js - About 35 mins to fix

                Function SELF has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        viewState,
                        $viewPort,
                        propertyDataTypeStore,
                        valueViewBuilder,
                        dataTypeStore
                Severity: Minor
                Found in view/resources/jquery/wikibase/snakview/snakview.variations.Variation.js - About 35 mins to fix

                  Function getSiteLinkListView has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      SELF.prototype.getSiteLinkListView = function ( startEditingCallback, siteLinks, $sitelinklistview, allowedSiteIds, $counter ) {
                  Severity: Minor
                  Found in view/resources/wikibase/view/ViewFactory.js - About 35 mins to fix

                    Function _attach has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            _attach: function ( source, target, event, handler, options ) {
                    Severity: Minor
                    Found in view/resources/jquery/jquery.util.EventSingletonManager.js - About 35 mins to fix

                      Function makeAssertionMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function makeAssertionMessage (path, key, type, value, expected) {
                      Severity: Minor
                      Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 35 mins to fix

                        Function ApiValueFormatter has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                function ( formatValueCaller, additionalOptions, dataTypeId, propertyId, outputType ) {
                        Severity: Minor
                        Found in repo/resources/formatters/ApiValueFormatter.js - About 35 mins to fix

                          Function register has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  register: function ( source, target, event, handler, options ) {
                          Severity: Minor
                          Found in view/resources/jquery/jquery.util.EventSingletonManager.js - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language