wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function modifyUsingUnflattenedCallbacks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function modifyUsingUnflattenedCallbacks( &$value, array $modifications ): void {
        $rootModifications = $modifications[''] ?? [];
        unset( $modifications[''] );

        if ( is_array( $value ) ) {
Severity: Minor
Found in lib/includes/Serialization/SerializationModifier.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

File OutputPageBeforeHTMLHookHandler.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Hooks;
Severity: Minor
Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php - About 2 hrs to fix

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

        private function newSuccessHttpResponse( SetItemDescriptionResponse $useCaseResponse ): Response {
            $httpResponse = $this->getResponseFactory()->create();
            $httpResponse->setStatus( $useCaseResponse->wasReplaced() ? 200 : 201 );
            $httpResponse->setHeader( 'Content-Type', 'application/json' );
            $httpResponse->setHeader( 'ETag', "\"{$useCaseResponse->getRevisionId()}\"" );
    repo/rest-api/src/RouteHandlers/SetItemLabelRouteHandler.php on lines 160..172
    repo/rest-api/src/RouteHandlers/SetPropertyDescriptionRouteHandler.php on lines 154..168
    repo/rest-api/src/RouteHandlers/SetPropertyLabelRouteHandler.php on lines 160..172

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

    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

        private function newSuccessHttpResponse( SetPropertyDescriptionResponse $useCaseResponse ): Response {
            $httpResponse = $this->getResponseFactory()->create();
            $httpResponse->setStatus( $useCaseResponse->wasReplaced() ? 200 : 201 );
            $httpResponse->setHeader( 'Content-Type', 'application/json' );
            $httpResponse->setHeader( 'ETag', "\"{$useCaseResponse->getRevisionId()}\"" );
    repo/rest-api/src/RouteHandlers/SetItemDescriptionRouteHandler.php on lines 159..173
    repo/rest-api/src/RouteHandlers/SetItemLabelRouteHandler.php on lines 160..172
    repo/rest-api/src/RouteHandlers/SetPropertyLabelRouteHandler.php on lines 160..172

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

    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

        protected function getAllowedParams(): array {
            return [
                'continue' => [
                    self::PARAM_HELP_MSG => 'api-help-param-continue',
                    ParamValidator::PARAM_TYPE => 'integer',
    Severity: Major
    Found in repo/includes/Api/EntityTerms.php and 1 other location - About 2 hrs to fix
    client/includes/Api/PageTerms.php on lines 269..287

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

    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

        protected function getAllowedParams(): array {
            return [
                'continue' => [
                    self::PARAM_HELP_MSG => 'api-help-param-continue',
                    ParamValidator::PARAM_TYPE => 'integer',
    Severity: Major
    Found in client/includes/Api/PageTerms.php and 1 other location - About 2 hrs to fix
    repo/includes/Api/EntityTerms.php on lines 267..285

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

    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

        private function newSuccessHttpResponse( SetPropertyLabelResponse $useCaseResponse ): Response {
            $httpResponse = $this->getResponseFactory()->create();
            $httpResponse->setStatus( $useCaseResponse->wasReplaced() ? 200 : 201 );
            $httpResponse->setHeader( 'Content-Type', 'application/json' );
            $httpResponse->setHeader( 'ETag', "\"{$useCaseResponse->getRevisionId()}\"" );
    repo/rest-api/src/RouteHandlers/SetItemDescriptionRouteHandler.php on lines 159..173
    repo/rest-api/src/RouteHandlers/SetItemLabelRouteHandler.php on lines 160..172
    repo/rest-api/src/RouteHandlers/SetPropertyDescriptionRouteHandler.php on lines 154..168

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

    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

        private function newSuccessHttpResponse( SetItemLabelResponse $useCaseResponse ): Response {
            $httpResponse = $this->getResponseFactory()->create();
            $httpResponse->setStatus( $useCaseResponse->wasReplaced() ? 200 : 201 );
            $httpResponse->setHeader( 'Content-Type', 'application/json' );
            $httpResponse->setHeader( 'ETag', "\"{$useCaseResponse->getRevisionId()}\"" );
    repo/rest-api/src/RouteHandlers/SetItemDescriptionRouteHandler.php on lines 159..173
    repo/rest-api/src/RouteHandlers/SetPropertyDescriptionRouteHandler.php on lines 154..168
    repo/rest-api/src/RouteHandlers/SetPropertyLabelRouteHandler.php on lines 160..172

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

    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

            repositionMenu: function () {
                $menu.position( {
                    of: this.$icon,
                    my: ( this.options.isRTL ? 'right' : 'left' ) + ' top',
                    at: ( this.options.isRTL ? 'right' : 'left' ) + ' bottom',
    view/resources/jquery/wikibase/jquery.wikibase.badgeselector.js on lines 437..445

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

    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

            repositionMenu: function () {
                $menu.position( {
                    of: this.element,
                    my: ( this.options.isRtl ? 'right' : 'left' ) + ' top',
                    at: ( this.options.isRtl ? 'right' : 'left' ) + ' bottom',
    view/resources/jquery/wikibase/jquery.wikibase.statementview.RankSelector.js on lines 312..320

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

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

            show: function() {
                var title = this.getTitle();
                if (title && this.enabled) {
                    var $tip = this.tip();
    
    
    Severity: Major
    Found in client/resources/jquery.wikibase/jquery.tipsy/jquery.tipsy.js - About 2 hrs to fix

      Function show has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              show: function() {
                  var title = this.getTitle();
                  if (title && this.enabled) {
                      var $tip = this.tip();
      
      
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.tipsy/jquery.tipsy.js - About 2 hrs to fix

        Method getDefaultTermsLanguages has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getDefaultTermsLanguages( LanguageNameUtils $languageNameUtils = null ) {
                // Note: this list is also the basis of getDefaultMonolingualTextLanguages(); custom
                // (non-MediaWikiContentLanguages) terms languages also become monolingual text languages.
                return new UnionContentLanguages(
                    new MediaWikiContentLanguages( $languageNameUtils ),
        Severity: Major
        Found in lib/includes/WikibaseContentLanguages.php - About 2 hrs to fix

          Function initBridge has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public initBridge(
                  information: AppInformation,
              ): Promise<void> {
                  this.commit( 'setEditFlow', information.editFlow );
                  this.commit( 'setPropertyPointer', information.propertyId );
          Severity: Major
          Found in client/data-bridge/src/store/actions.ts - About 2 hrs to fix

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

            $specialPageAliases['cdo'] = [
                'DispatchStats' => [ '特派統計' ],
                'EntityData' => [ '條目數據' ],
                'ItemByTitle' => [ '標題其單單' ],
                'ItemDisambiguation' => [ '消除歧義其單單' ],
            Severity: Major
            Found in repo/Wikibase.i18n.alias.php and 1 other location - About 2 hrs to fix
            repo/Wikibase.i18n.alias.php on lines 435..449

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

            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

            $specialPageAliases['sv'] = [
                'EntityData' => [ 'Objektdata' ],
                'ItemByTitle' => [ 'Objekt_efter_titel' ],
                'ItemDisambiguation' => [ 'Objektsärskiljning' ],
                'ItemsWithoutSitelinks' => [ 'Objekt_utan_webbplatslänk' ],
            Severity: Major
            Found in repo/Wikibase.i18n.alias.php and 1 other location - About 2 hrs to fix
            repo/Wikibase.i18n.alias.php on lines 111..125

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

            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

            CachingPrefetchingTermLookup has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            final class CachingPrefetchingTermLookup implements PrefetchingTermLookup {
            
                use TermCacheKeyBuilder;
            
                private const DEFAULT_TTL = 60;
            Severity: Minor
            Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 2 hrs to fix

              Function _attachInputEventHandlers has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _attachInputEventHandlers: function () {
                          var self = this,
                              suppressKeyPress = false;
              
                          this.element
              Severity: Major
              Found in client/resources/jquery.ui/jquery.ui.suggester.js - About 2 hrs to fix

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

                  File RdfVocabulary.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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