wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

( function () {
    'use strict';

    var MODULE = require( './snakview.variations.js' ),
        PARENT = require( './snakview.variations.Variation.js' ),
view/resources/jquery/wikibase/snakview/snakview.variations.SomeValue.js on lines 1..37

Duplicated Code

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

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

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

Tuning

This issue has a mass of 117.

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';

    var MODULE = require( './snakview.variations.js' ),
        PARENT = require( './snakview.variations.Variation.js' ),
view/resources/jquery/wikibase/snakview/snakview.variations.NoValue.js 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 117.

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

    private function filterEntitySerializationUsingLangCodes( array $serialization ) {
        if ( $this->filterLangCodes ) {
            if ( array_key_exists( 'labels', $serialization ) ) {
                foreach ( $serialization['labels'] as $langCode => $languageArray ) {
                    if ( !in_array( $langCode, $this->filterLangCodes ) ) {
Severity: Minor
Found in client/includes/Serializer/ClientEntitySerializer.php - About 4 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 filterEntitySerializationUsingLangCodes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    private function filterEntitySerializationUsingLangCodes(
        array $serialization,
        array $langCodes
    ) {
        if ( $langCodes ) {
Severity: Minor
Found in repo/includes/Api/ResultBuilder.php - About 4 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

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

        destroy: function () {
            if ( this.isInEditMode() ) {
                var self = this;

                this.element.one( this.widgetEventPrefix + 'afterstopediting', function ( event ) {
Severity: Major
Found in view/resources/jquery/wikibase/jquery.wikibase.labelview.js and 1 other location - About 4 hrs to fix
view/resources/jquery/wikibase/jquery.wikibase.descriptionview.js on lines 89..101

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

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

        _getRemovedAliasesTexts: function ( currentAliases, initialAliases ) {
            var currentTexts = currentAliases.getTexts(),
                initialTexts = initialAliases.getTexts(),
                removedAliases = [];

Severity: Major
Found in view/resources/wikibase/entityChangers/AliasesChanger.js and 1 other location - About 4 hrs to fix
view/resources/wikibase/entityChangers/AliasesChanger.js on lines 98..110

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

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

        destroy: function () {
            if ( this.isInEditMode() ) {
                var self = this;

                this.element.one( this.widgetEventPrefix + 'afterstopediting', function ( event ) {
view/resources/jquery/wikibase/jquery.wikibase.labelview.js on lines 90..102

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

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

        _getNewAliasesTexts: function ( currentAliases, initialAliases ) {
            var currentTexts = currentAliases.getTexts(),
                initialTexts = initialAliases.getTexts(),
                newAliases = [];

Severity: Major
Found in view/resources/wikibase/entityChangers/AliasesChanger.js and 1 other location - About 4 hrs to fix
view/resources/wikibase/entityChangers/AliasesChanger.js on lines 117..129

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

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 jquery.wikibase.sitelinkview.js has 335 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.sitelinkview.js - About 4 hrs to fix

    Function showCopyrightTooltip has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function showCopyrightTooltip( $entityview, $origin, gravity, viewName ) {
            if ( !mw.config.exists( 'wbCopyright' ) ) {
                return;
            }
    
    
    Severity: Major
    Found in repo/resources/wikibase.ui.entityViewInit.js - About 4 hrs to fix

      File WikibaseValueFormatterBuilders.php has 335 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare( strict_types = 1 );
      
      namespace Wikibase\Lib\Formatters;
      Severity: Minor
      Found in lib/includes/Formatters/WikibaseValueFormatterBuilders.php - About 4 hrs to fix

        File jquery.wikibase.sitelinklistview.js has 333 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.sitelinklistview.js - About 4 hrs to fix

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

              public static function factory(): self {
                  $responseFactory = new ResponseFactory();
                  return new self(
                      WbRestApi::getAddPropertyStatement(),
                      WbRestApi::getStatementSerializer(),
          repo/rest-api/src/RouteHandlers/AddItemStatementRouteHandler.php on lines 58..75

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

          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 static function factory(): Handler {
                  $responseFactory = new ResponseFactory();
                  return new self(
                      WbRestApi::getAddItemStatement(),
                      WbRestApi::getStatementSerializer(),
          repo/rest-api/src/RouteHandlers/AddPropertyStatementRouteHandler.php on lines 56..73

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

          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

              'property' => [
                  Def::SERIALIZER_FACTORY_CALLBACK => function( SerializerFactory $serializerFactory ) {
                      return $serializerFactory->newPropertySerializer();
                  },
                  Def::DESERIALIZER_FACTORY_CALLBACK => function( DeserializerFactory $deserializerFactory ) {
          Severity: Major
          Found in lib/WikibaseLib.entitytypes.php and 1 other location - About 3 hrs to fix
          lib/WikibaseLib.entitytypes.php on lines 29..49

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

          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

              'item' => [
                  Def::SERIALIZER_FACTORY_CALLBACK => function( SerializerFactory $serializerFactory ) {
                      return $serializerFactory->newItemSerializer();
                  },
                  Def::DESERIALIZER_FACTORY_CALLBACK => function( DeserializerFactory $deserializerFactory ) {
          Severity: Major
          Found in lib/WikibaseLib.entitytypes.php and 1 other location - About 3 hrs to fix
          lib/WikibaseLib.entitytypes.php on lines 50..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 161.

          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 97 lines of code (exceeds 25 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: Major
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 3 hrs to fix

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

                protected function getAllowedParams(): array {
                    return array_merge(
                        [
                            'claim' => [
                                ParamValidator::PARAM_TYPE => 'string',
            Severity: Major
            Found in repo/includes/Api/RemoveQualifiers.php and 1 other location - About 3 hrs to fix
            repo/includes/Api/RemoveReferences.php on lines 232..260

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

            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 runUseCase( string $itemId, string $siteId ): Response {
                    $jsonBody = $this->getValidatedBody();
                    '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
            
                    try {
            Severity: Major
            Found in repo/rest-api/src/RouteHandlers/SetSitelinkRouteHandler.php and 1 other location - About 3 hrs to fix
            repo/rest-api/src/RouteHandlers/SetItemDescriptionRouteHandler.php on lines 78..103

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

            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 array_merge(
                        [
                            'statement' => [
                                ParamValidator::PARAM_TYPE => 'string',
            Severity: Major
            Found in repo/includes/Api/RemoveReferences.php and 1 other location - About 3 hrs to fix
            repo/includes/Api/RemoveQualifiers.php on lines 235..263

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

            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

            Severity
            Category
            Status
            Source
            Language