wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function getRankedSearchResults has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRankedSearchResults(
        $text,
        $languageCode,
        $entityType,
        $limit,
Severity: Minor
Found in repo/includes/FederatedProperties/ApiEntitySearchHelper.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 onApiCheckCanExecute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function onApiCheckCanExecute( ApiBase $module, User $user, &$message ) {
        if ( $module instanceof ApiEditPage ) {
            $params = $module->extractRequestParams();
            $pageObj = $module->getTitleOrPageId( $params );
            $namespace = $pageObj->getTitle()->getNamespace();
Severity: Minor
Found in repo/includes/RepoHooks.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

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

            this.element
            .on( prefix + 'change.' + this.widgetName, function ( event, lang ) {
                event.stopPropagation();
                // The only event handler for this is in entitytermsview.
                self._trigger( 'change', null, [ lang ] );
view/resources/jquery/wikibase/jquery.wikibase.entitytermsview.js on lines 359..377

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

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.$entitytermsforlanguagelistview
            .on( prefix + 'change.' + this.widgetName, function ( event, lang ) {
                event.stopPropagation();
                // Event handlers for this are in the entitytermsview toolbar controller (for enabling
                // the save button), in entityViewInit (for updating the title) and in this file (for
view/resources/jquery/wikibase/jquery.wikibase.entitytermsforlanguagelistview.js on lines 190..210

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

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

        focus: function () {
            if ( this.isInEditMode() ) {
                this.$text.children( '.' + this.widgetFullName + '-input' ).trigger( 'focus' );
            } else {
                this.element.trigger( 'focus' );
view/resources/jquery/wikibase/jquery.wikibase.labelview.js on lines 277..283

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

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

        focus: function () {
            if ( this.isInEditMode() ) {
                this.$text.children( '.' + this.widgetFullName + '-input' ).trigger( 'focus' );
            } else {
                this.element.trigger( 'focus' );
Severity: Major
Found in view/resources/jquery/wikibase/jquery.wikibase.labelview.js and 1 other location - About 2 hrs to fix
view/resources/jquery/wikibase/jquery.wikibase.descriptionview.js on lines 249..255

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

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

( function () {
    'use strict';

    require( './jquery.wikibase.singlebuttontoolbar.js' );

view/resources/jquery/wikibase/toolbar/jquery.wikibase.addtoolbar.js on lines 5..34

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

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

( function () {
    'use strict';

    require( './jquery.wikibase.singlebuttontoolbar.js' );

view/resources/jquery/wikibase/toolbar/jquery.wikibase.removetoolbar.js on lines 1..35

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

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 initialize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        LeavingSiteNoticeDialog.prototype.initialize = function () {
            LeavingSiteNoticeDialog.super.prototype.initialize.apply( this, arguments );
            var dialog = this;

            var inputCheckbox = new OO.ui.CheckboxInputWidget( {
Severity: Major
Found in repo/resources/wikibase.federatedPropertiesLeavingSiteNotice.js - About 2 hrs to fix

    Method validateFormData has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function validateFormData( array $formData ): Status {
            $status = Status::newGood();
    
            if ( $formData[ self::FIELD_LABEL ] == ''
                 && $formData[ self::FIELD_DESCRIPTION ] == ''
    Severity: Major
    Found in repo/includes/Specials/SpecialNewItem.php - About 2 hrs to fix

      File SetReference.php has 260 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/SetReference.php - About 2 hrs to fix

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

            public function execute(): void {
                if ( !WikibaseSettings::isRepoEnabled() ) {
                    $this->output( "You need to have Wikibase enabled in order to use this maintenance script!\n\n" );
                    exit;
                }
        Severity: Major
        Found in repo/maintenance/rebuildItemsPerSite.php - About 2 hrs to fix

          Method cleanTextInLangIds has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function cleanTextInLangIds( array $textInLangIds ): void {
                  if ( $textInLangIds === [] ) {
                      return;
                  }
          
          
          Severity: Major
          Found in lib/includes/Store/Sql/Terms/DatabaseInnerTermStoreCleaner.php - About 2 hrs to fix

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

                public function validateAndDeserialize(
                    TermList $originalDescriptions,
                    TermList $originalLabels,
                    $descriptionsSerialization
                ): TermList {
            repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedItemLabelsValidator.php on lines 36..57
            repo/rest-api/src/Application/UseCases/PatchPropertyDescriptions/PatchedPropertyDescriptionsValidator.php on lines 36..56
            repo/rest-api/src/Application/UseCases/PatchPropertyLabels/PatchedPropertyLabelsValidator.php on lines 36..57

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

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

                public function validateAndDeserialize(
                    TermList $originalLabels,
                    TermList $originalDescriptions,
                    $labelsSerialization
                ): TermList {
            repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedItemDescriptionsValidator.php on lines 36..56
            repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedItemLabelsValidator.php on lines 36..57
            repo/rest-api/src/Application/UseCases/PatchPropertyDescriptions/PatchedPropertyDescriptionsValidator.php on lines 36..56

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

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

                public function validateAndDeserialize(
                    TermList $originalLabels,
                    TermList $originalDescriptions,
                    $labelsSerialization
                ): TermList {
            repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedItemDescriptionsValidator.php on lines 36..56
            repo/rest-api/src/Application/UseCases/PatchPropertyDescriptions/PatchedPropertyDescriptionsValidator.php on lines 36..56
            repo/rest-api/src/Application/UseCases/PatchPropertyLabels/PatchedPropertyLabelsValidator.php on lines 36..57

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

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

                public function validateAndDeserialize(
                    TermList $originalDescriptions,
                    TermList $originalLabels,
                    $descriptionsSerialization
                ): TermList {
            repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedItemDescriptionsValidator.php on lines 36..56
            repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedItemLabelsValidator.php on lines 36..57
            repo/rest-api/src/Application/UseCases/PatchPropertyLabels/PatchedPropertyLabelsValidator.php on lines 36..57

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

            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 __construct(
                    NamespaceChecker $namespaceChecker,
                    JobQueueGroupFactory $jobQueueGroupFactory,
                    DatabaseEntitySource $entitySource,
                    SiteLinkLookup $siteLinkLookup,
            Severity: Major
            Found in client/includes/Hooks/UpdateRepoHookHandler.php and 1 other location - About 2 hrs to fix
            repo/includes/Store/PropertyTermsRebuilder.php on lines 45..63

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

            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 __construct(
                    PropertyTermStoreWriter $propertyTermStoreWriter,
                    SeekableEntityIdPager $idPager,
                    MessageReporter $progressReporter,
                    MessageReporter $errorReporter,
            Severity: Major
            Found in repo/includes/Store/PropertyTermsRebuilder.php and 1 other location - About 2 hrs to fix
            client/includes/Hooks/UpdateRepoHookHandler.php on lines 70..89

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

            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

            File DateFormatParser.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Wikibase\Repo\Parsers;
            
            use DataValues\IllegalValueException;
            Severity: Minor
            Found in repo/includes/Parsers/DateFormatParser.php - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language