wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                    this._pageConnector.linkPages()
                    .done( this._onSuccess.bind( this ) )
                    .fail( this._onError.bind( this ) );
Severity: Minor
Found in client/resources/jquery.wikibase/jquery.wikibase.linkitem.js and 1 other location - About 55 mins to fix
client/resources/jquery.wikibase/jquery.wikibase.linkitem.js on lines 460..462

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                this._pageConnector.linkPages()
                .done( this._onSuccess.bind( this ) )
                .fail( this._onError.bind( this ) );
Severity: Minor
Found in client/resources/jquery.wikibase/jquery.wikibase.linkitem.js and 1 other location - About 55 mins to fix
client/resources/jquery.wikibase/jquery.wikibase.linkitem.js on lines 451..453

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export interface Dialog extends OOElement {
    $body: JQuery;
    getBodyHeight(): number;
    close( data?: object ): WindowInstance;
    getManager(): WindowManager;
Severity: Minor
Found in client/data-bridge/src/@types/mediawiki/MwWindow.ts and 1 other location - About 55 mins to fix
view/lib/wikibase-tainted-ref/src/@types/mediawiki/MwWindow.ts on lines 90..95

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export interface Dialog extends OOElement {
    $body: JQuery;
    getBodyHeight(): number;
    close( data?: object ): WindowInstance;
    getManager(): WindowManager;
Severity: Minor
Found in view/lib/wikibase-tainted-ref/src/@types/mediawiki/MwWindow.ts and 1 other location - About 55 mins to fix
client/data-bridge/src/@types/mediawiki/MwWindow.ts on lines 121..126

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

declare( strict_types=1 );

namespace Wikibase\Lib\Formatters;
Severity: Minor
Found in lib/includes/Formatters/NumberLocalizerFactory.php and 1 other location - About 55 mins to fix
repo/includes/LocalizedTextProviderFactory.php on lines 1..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 98.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php declare( strict_types=1 );

namespace Wikibase\Repo\RestApi\Application\Validation;

use Wikibase\DataModel\Term\TermList;
repo/rest-api/src/Application/Validation/ItemLabelValidator.php on lines 1..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 98.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php declare( strict_types=1 );

namespace Wikibase\Repo\RestApi\Application\Validation;

use Wikibase\DataModel\Term\TermList;
Severity: Minor
Found in repo/rest-api/src/Application/Validation/ItemLabelValidator.php and 1 other location - About 55 mins to fix
repo/rest-api/src/Application/Validation/ItemDescriptionValidator.php on lines 1..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 98.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

declare( strict_types=1 );

namespace Wikibase\Repo;
Severity: Minor
Found in repo/includes/LocalizedTextProviderFactory.php and 1 other location - About 55 mins to fix
lib/includes/Formatters/NumberLocalizerFactory.php on lines 1..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 98.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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
                Severity
                Category
                Status
                Source
                Language