wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

Module.prototype.forEachAction = function forEachAction (fn) {
  if (this._rawModule.actions) {
    forEachValue(this._rawModule.actions, fn);
  }
};
Severity: Major
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js and 2 other locations - About 55 mins to fix
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2965..2969
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2977..2981

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 54.

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 3 locations. Consider refactoring.
Open

Module.prototype.forEachMutation = function forEachMutation (fn) {
  if (this._rawModule.mutations) {
    forEachValue(this._rawModule.mutations, fn);
  }
};
Severity: Major
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js and 2 other locations - About 55 mins to fix
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2965..2969
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2971..2975

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 54.

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

            $input
            .addClass( this.widgetFullName + '-input' )
            .attr( 'placeholder', mw.msg(
                // The following messages can be used here:
                // * wikibase-description-edit-placeholder-language-aware
view/resources/jquery/wikibase/jquery.wikibase.labelview.js on lines 188..198

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 54.

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 3 locations. Consider refactoring.
Open

Module.prototype.forEachGetter = function forEachGetter (fn) {
  if (this._rawModule.getters) {
    forEachValue(this._rawModule.getters, fn);
  }
};
Severity: Major
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js and 2 other locations - About 55 mins to fix
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2971..2975
view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js on lines 2977..2981

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 54.

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

    public function attemptSave(
        EntityDocument $newEntity,
        string $summary,
        $flags,
        $token,
Severity: Minor
Found in repo/includes/EditEntity/StatsdSaveTimeRecordingEditEntity.php and 1 other location - About 55 mins to fix
repo/includes/EditEntity/StatsdSaveTimeRecordingEntityStore.php on lines 44..62

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 99.

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

    public function saveEntity(
        EntityDocument $entity,
        $summary,
        User $user,
        $flags = 0,
Severity: Minor
Found in repo/includes/EditEntity/StatsdSaveTimeRecordingEntityStore.php and 1 other location - About 55 mins to fix
repo/includes/EditEntity/StatsdSaveTimeRecordingEditEntity.php on lines 68..86

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 99.

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

/***/ (function(module, exports, __webpack_require__) {

var global = __webpack_require__("da84");
var shared = __webpack_require__("5692");
var has = __webpack_require__("5135");
Severity: Minor
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - 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 94ca has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

/***/ (function(module, exports, __webpack_require__) {

var fails = __webpack_require__("d039");

var replacement = /#|\.prototype\./;
Severity: Minor
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - 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 d2bb has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

/***/ (function(module, exports, __webpack_require__) {

/* eslint-disable no-proto -- safe */
var anObject = __webpack_require__("825a");
var aPossiblePrototype = __webpack_require__("3bbe");
Severity: Minor
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - 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 ca84 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

/***/ (function(module, exports, __webpack_require__) {

var has = __webpack_require__("5135");
var toIndexedObject = __webpack_require__("fc6a");
var indexOf = __webpack_require__("4d64").indexOf;
Severity: Minor
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - 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 getTerm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTerm( EntityId $entityId, string $languageCode, string $termType ): ?string {
        $resolutionResult = $this->redirectResolvingLatestRevisionLookup->lookupLatestRevisionResolvingRedirect( $entityId );
        if ( $resolutionResult === null ) {
            return null;
        }
Severity: Minor
Found in client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.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 getChangedAspects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getChangedAspects( EntityChange $change ) {
        $aspects = [];
        $diffAspects = $change->getCompactDiff();

        if ( $diffAspects->getSiteLinkChanges() !== [] ) {
Severity: Minor
Found in client/includes/Changes/AffectedPagesFinder.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 rebuildTermsForBatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function rebuildTermsForBatch( array $itemIds ) {
        foreach ( $itemIds as $itemId ) {
            try {
                $item = $this->itemLookup->getItemForId( $itemId );
            } catch ( UnresolvedEntityRedirectException $entityRedirectException ) {
Severity: Minor
Found in repo/includes/Store/ItemTermsRebuilder.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 generateOpHtml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function generateOpHtml( array $path, DiffOp $op ) {
        if ( $op->isAtomic() ) {
            $localizedPath = $path;

            $html = $this->generateDiffHeaderHtml( implode( ' / ', $localizedPath ) );
Severity: Minor
Found in repo/includes/Diff/BasicDiffView.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 rebuild has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function rebuild() {
        $ticket = $this->db->getEmptyTransactionTicket( __METHOD__ );

        while ( true ) {
            $propertyIds = $this->idPager->fetchIds( $this->batchSize );
Severity: Minor
Found in repo/includes/Store/PropertyTermsRebuilder.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 getEntityIdsToFetch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEntityIdsToFetch( array $entityIds, array $termTypes, array $languageCodes ): array {
        /** @var EntityId[] serialization -> EntityId */
        $entityIdsToFetch = [];

        foreach ( $entityIds as $entityId ) {
Severity: Minor
Found in repo/includes/FederatedProperties/ApiPrefetchingTermLookup.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 getTitleForNotification has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTitleForNotification( DiffOp $siteLinkDiffOp ) {
        if ( $siteLinkDiffOp instanceof DiffOpAdd ) {
            $new = $siteLinkDiffOp->getNewValue();
            $newTitle = Title::newFromText( $new );
            return $this->canNotifyForTitle( $newTitle ) ? $newTitle : false;
Severity: Minor
Found in client/includes/Hooks/EchoNotificationsHandlers.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 handleDisabledUsages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleDisabledUsages( array $usages ): array {
        $newUsages = [];

        foreach ( $usages as $usage ) {
            if ( !( $usage instanceof EntityUsage ) ) {
Severity: Minor
Found in client/includes/Usage/Sql/SqlUsageTracker.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 rebuildSiteLinks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function rebuildSiteLinks( array $itemIds ): int {
        $this->entityPrefetcher->prefetch( $itemIds );

        $c = 0;
        foreach ( $itemIds as $itemId ) {
Severity: Minor
Found in repo/includes/Store/Sql/ItemsPerSiteBuilder.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 adjustFlagsForMCR has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function adjustFlagsForMCR( $flags, $parentRevision, $slotRole ) {
        if ( $flags & EDIT_UPDATE ) {
            if ( !$parentRevision ) {
                throw new StorageException( 'Can\'t perform an update with no parent revision' );
            }
Severity: Minor
Found in repo/includes/Store/Sql/WikiPageEntityStore.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

Severity
Category
Status
Source
Language