wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

    public static function factory(): self {
        $responseFactory = new ResponseFactory();
        return new self(
            WbRestApi::getSetItemDescription(),
            $responseFactory,
repo/rest-api/src/RouteHandlers/AddItemAliasesInLanguageRouteHandler.php on lines 56..72
repo/rest-api/src/RouteHandlers/SetPropertyDescriptionRouteHandler.php on lines 52..68
repo/rest-api/src/RouteHandlers/SetPropertyLabelRouteHandler.php on lines 53..70

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

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

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

var toIndexedObject = __webpack_require__("fc6a");
var toLength = __webpack_require__("50c4");
var toAbsoluteIndex = __webpack_require__("23cb");
Severity: Minor
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 3 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 getStatus has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
        if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
            $olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );

            if ( !$olderRevision ) {
Severity: Minor
Found in repo/includes/Actions/EditEntityAction.php - About 3 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 SearchEntities.php has 315 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/SearchEntities.php - About 3 hrs to fix

    Method getLocalizedYear has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getLocalizedYear( $isoTimestamp, $precision ) {
            preg_match( '/^(\D*)(\d*)/', $isoTimestamp, $matches );
            [ , $sign, $year ] = $matches;
            $isBCE = $sign === '-';
    
    
    Severity: Major
    Found in lib/includes/Formatters/MwTimeIsoFormatter.php - About 3 hrs to fix

      File jquery.wikibase.entitytermsview.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * @license GPL-2.0-or-later
       * @author H. Snater < mediawiki@snater.com >
       */
      ( function ( wb ) {
      Severity: Minor
      Found in view/resources/jquery/wikibase/jquery.wikibase.entitytermsview.js - About 3 hrs to fix

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

                focus: function () {
                    var listview = this.$listview.data( 'listview' ),
                        $items = listview.items();
        
                    if ( $items.length ) {
        view/resources/jquery/wikibase/jquery.wikibase.sitelinkgrouplistview.js on lines 184..193

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

        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

                focus: function () {
                    var listview = this.$listview.data( 'listview' ),
                        $items = listview.items();
        
                    if ( $items.length ) {
        view/resources/jquery/wikibase/jquery.wikibase.entitytermsforlanguagelistview.js on lines 529..538

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

        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
        
        namespace Wikibase\InternalSerialization\Deserializers;
        
        use Deserializers\DispatchableDeserializer;
        lib/packages/wikibase/internal-serialization/src/Deserializers/StatementDeserializer.php on lines 1..66

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

        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
        
        namespace Wikibase\InternalSerialization\Deserializers;
        
        use Deserializers\DispatchableDeserializer;
        lib/packages/wikibase/internal-serialization/src/Deserializers/EntityDeserializer.php on lines 1..66

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

        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 PatchedPropertyValidator.php has 311 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php declare( strict_types=1 );
        
        namespace Wikibase\Repo\RestApi\Application\UseCases\PatchProperty;
        
        use LogicException;

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

          <?php declare( strict_types=1 );
          
          namespace Wikibase\Repo\RestApi\Application\UseCaseRequestValidation;
          
          use Wikibase\DataModel\Statement\StatementGuid;
          repo/rest-api/src/Application/UseCaseRequestValidation/ItemStatementIdRequestValidator.php on lines 1..36

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

          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\UseCaseRequestValidation;
          
          use Wikibase\DataModel\Statement\StatementGuid;
          repo/rest-api/src/Application/UseCaseRequestValidation/PropertyStatementIdRequestValidator.php on lines 1..36

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

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

          /***/ (function(module, __webpack_exports__, __webpack_require__) {
          
          "use strict";
          /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ApiProxy; });
          /* harmony import */ var _const__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("b774");
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 3 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 initFormats has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private function initFormats() {
                  if ( $this->mimeTypes !== null && $this->fileExtensions !== null ) {
                      return;
                  }
          
          
          Severity: Minor
          Found in repo/includes/LinkedData/EntityDataFormatProvider.php - About 3 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 constructor has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              constructor(plugin, hook) {
                  this.target = null;
                  this.targetQueue = [];
                  this.onQueue = [];
                  this.plugin = plugin;
          Severity: Major
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 3 hrs to fix

            File jquery.ui.tagadata.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * 'tag-a-data' jQuery widget
             *
             * 'tag-a-data' is based on the original jQuery extension 'tag-it' v2.0 (06/2011) by
             *   Levy Carneiro Jr.
            Severity: Minor
            Found in view/resources/jquery/ui/jquery.ui.tagadata.js - About 3 hrs to fix

              File GetEntities.php has 304 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/GetEntities.php - About 3 hrs to fix

                Function createEntityView has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function createEntityView( entity, $entityview ) {
                        var currentRevision, revisionStore, entityChangersFactory,
                            viewFactoryArguments, ViewFactoryFactory, viewFactory, entityView,
                            repoConfig = mw.config.get( 'wbRepo' ),
                            repoApiUrl = repoConfig.url + repoConfig.scriptPath + '/api.php',
                Severity: Major
                Found in repo/resources/wikibase.ui.entityViewInit.js - About 3 hrs to fix

                  Function hydrateLanguageLabelInputForm has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var hydrateLanguageLabelInputForm = function () {
                          var $lang, fields, fieldCount, langWidget;
                  
                          $lang = $( document.getElementsByName( 'lang' ) ).closest( '.oo-ui-inputWidget' );
                          if ( $lang.length === 0 ) {
                    Severity
                    Category
                    Status
                    Source
                    Language