wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function findPrimaryCoordinateKey has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function findPrimaryCoordinateKey() {
        foreach ( $this->preferredPropertiesIds as $id ) {
            $key = $this->makeCoordinateKey( $id, Statement::RANK_PREFERRED );
            $preferredCount = $this->getCoordinatesGroupCount( $key );

Severity: Minor
Found in repo/includes/ParserOutput/GeoDataDataUpdater.php - About 55 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 deserialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function deserialize( array $serialization, string $basePath ): array {
        if ( !count( $serialization ) || !array_is_list( $serialization ) ) {
            $parts = explode( '/', $basePath );
            throw new InvalidFieldException( $parts[array_key_last( $parts )], $serialization, $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 getHtml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHtml( TermFallback $term ) {
        $requestedLanguage = $term->getLanguageCode();
        $actualLanguage = $term->getActualLanguageCode();
        $sourceLanguage = $term->getSourceLanguageCode();

Severity: Minor
Found in lib/includes/LanguageFallbackIndicator.php - About 55 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 __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $fields = [] ) {
        Assert::parameter(
            !array_diff( array_keys( $fields ), self::FIELD_NAMES ),
            '$fields',
            'must only contain the following keys: termType, termLanguage, termText'
Severity: Minor
Found in lib/includes/Store/TermIndexSearchCriteria.php - About 55 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 toStandardUnits has a Cognitive Complexity of 9 (exceeds 5 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 55 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 getLinks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLinks(
        ?array $numericIds = null,
        ?array $siteIds = null,
        ?array $pageNames = null
    ): array {
Severity: Minor
Found in lib/includes/Store/Sql/SiteLinkTable.php - About 55 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 getAmountAndPrecisionHtml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getAmountAndPrecisionHtml( $precision, $amount = 1 ) {
        if ( $amount === 0 ) {
            // TODO: Use NumberLocalizer
            return '0';
        }
Severity: Minor
Found in lib/includes/Formatters/TimeDetailsFormatter.php - About 55 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 getPatchedAliases has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getPatchedAliases( array $aliases, Diff $patch ) {
        foreach ( $patch as $diffOp ) {
            switch ( true ) {
                case $diffOp instanceof DiffOpAdd:
                    $aliases[] = $diffOp->getNewValue();

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

    private function patchTerm( TermList $terms, $lang, AtomicDiffOp $diffOp ) {
        $hasLang = $terms->hasTermForLanguage( $lang );

        switch ( true ) {
            case $diffOp instanceof DiffOpAdd:
Severity: Minor
Found in lib/packages/wikibase/data-model-services/src/Diff/TermListPatcher.php - About 55 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 getReferencedEntityId has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getReferencedEntityId( EntityId $fromId, PropertyId $propertyId, array $toIds ) {
        if ( !$toIds ) {
            return null;
        }

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

    private function buildEntityTypeToDatabaseSourceMapping() {
        $this->entityTypeToDatabaseSourceMapping = [];
        foreach ( $this->sources as $source ) {
            if ( $source->getType() === DatabaseEntitySource::TYPE ) {
                $entityTypes = $source->getEntityTypes();
Severity: Minor
Found in data-access/src/EntitySourceDefinitions.php - About 55 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 exports has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
Severity: Major
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 50 mins to fix

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

            EntityIdParser $entityIdParser,
            EntityIdLookup $entityIdLookup,
            WikibaseServices $wikibaseServices,
            SettingsArray $settings,
            TermBuffer $termBuffer,
    Severity: Major
    Found in client/includes/Store/Sql/DirectSqlStore.php - About 50 mins to fix

      Method onArticleDeleteComplete has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $wikiPage,
              $user,
              $reason,
              $id,
              $content,
      Severity: Major
      Found in client/includes/Hooks/UpdateRepoHookHandler.php - About 50 mins to fix

        Method onPageMoveComplete has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                $oldLinkTarget,
                $newLinkTarget,
                $userIdentity,
                $pageId,
                $redirid,
        Severity: Major
        Found in client/includes/Hooks/UpdateRepoHookHandler.php - About 50 mins to fix

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

                  TermFallbackCacheFacade $termFallbackCacheFacade,
                  RedirectResolvingLatestRevisionLookup $redirectResolvingLatestRevisionLookup,
                  LanguageFallbackChainFactory $languageFallbackChainFactory,
                  TermLookup $termLookup,
                  LanguageFactory $languageFactory,
          Severity: Major
          Found in client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php - About 50 mins to fix

            Method onChangesListSpecialPageQuery has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function onChangesListSpecialPageQuery( $name, &$tables, &$fields,
                        &$conds, &$query_options, &$join_conds, $opts ) {
            Severity: Major
            Found in client/includes/Hooks/ChangesListSpecialPageHookHandler.php - About 50 mins to fix

              Method onArticleDeleteComplete has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function onArticleDeleteComplete( $wikiPage, $user, $reason, $id,
                      $content, $logEntry, $archivedRevisionCount
              Severity: Major
              Found in client/includes/Hooks/DataUpdateHookHandler.php - About 50 mins to fix

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

                        SiteLinkLookup $siteLinkLookup,
                        LoggerInterface $logger,
                        ClientDomainDb $clientDomainDb,
                        UserIdentity $user,
                        $siteId,
                Severity: Major
                Found in client/includes/UpdateRepo/UpdateRepoOnMove.php - About 50 mins to fix

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

                          $userName,
                          $timestamp,
                          $comment,
                          $commentHtml,
                          $siteId,
                  Severity: Major
                  Found in client/includes/RecentChanges/RevisionData.php - About 50 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language