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

    private function buildResult( EntityId $entityId = null, Term $oldLabel = null, Term $newLabel = null ) {
        $isEntityChanged = false;
        $oldLabelText = $oldLabel ? $oldLabel->getText() : '';
        $newLabelText = $newLabel ? $newLabel->getText() : '';

Severity: Major
Found in repo/includes/ChangeOp/ChangeOpLabel.php and 1 other location - About 2 hrs to fix
repo/includes/ChangeOp/ChangeOpDescription.php on lines 82..96

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

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

<?php

declare( strict_types = 1 );

namespace Wikibase\Client\RecentChanges;
Severity: Minor
Found in client/includes/RecentChanges/ChangeLineFormatter.php - About 2 hrs to fix

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

        public static function factory(): Handler {
            $responseFactory = new ResponseFactory();
            return new self(
                WbRestApi::getGetItemStatement(),
                WbRestApi::getStatementSerializer(),
    repo/rest-api/src/RouteHandlers/GetPropertyStatementRouteHandler.php on lines 49..68

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

    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::getGetPropertyStatement(),
                WbRestApi::getStatementSerializer(),
    repo/rest-api/src/RouteHandlers/GetItemStatementRouteHandler.php on lines 50..69

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

    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\UseCases\RemoveItemStatement;
    
    use Wikibase\Repo\RestApi\Application\UseCases\AssertItemExists;
    repo/rest-api/src/Application/UseCases/RemovePropertyStatement/RemovePropertyStatement.php on lines 1..39

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

    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\UseCases\RemovePropertyStatement;
    
    use Wikibase\Repo\RestApi\Application\UseCases\AssertPropertyExists;
    repo/rest-api/src/Application/UseCases/RemoveItemStatement/RemoveItemStatement.php on lines 1..41

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

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

    <?php
    
    namespace Wikibase\Repo\Store\Sql;
    
    use MediaWiki\HookContainer\HookContainer;
    Severity: Minor
    Found in repo/includes/Store/Sql/SqlStore.php - About 2 hrs to fix

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

                      if ( mw.user.isAnon() ) {
                          mw.cookie.set( cookieKey, selected, { expires: 3 * 365 * 24 * 60 * 60, path: '/' } );
                      } else {
                          var api = new mw.Api();
                          api.saveOption( optionsKey, selected );
      repo/resources/wikibase.ui.entityViewInit.js on lines 269..274
      repo/resources/wikibase.ui.entityViewInit.js on lines 315..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 92.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  if ( mw.user.isAnon() ) {
                      mw.cookie.set( cookieKey, copyRightVersion, { expires: 3 * 365 * 24 * 60 * 60, path: '/' } );
                  } else {
                      var api = new mw.Api();
                      api.saveOption( optionsKey, copyRightVersion );
      Severity: Major
      Found in repo/resources/wikibase.ui.entityViewInit.js and 2 other locations - About 2 hrs to fix
      repo/resources/wikibase.federatedPropertiesLeavingSiteNotice.js on lines 58..63
      repo/resources/wikibase.ui.entityViewInit.js on lines 269..274

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

      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

              _evaluateGravity: function ( gravity ) {
                  if ( document.documentElement.dir === 'rtl' ) {
                      if ( gravity.search( /e/ ) !== -1 ) {
                          gravity = gravity.replace( /e/g, 'w' );
                      } else {
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.wikibase.wbtooltip.js and 1 other location - About 2 hrs to fix
      client/resources/jquery.wikibase/jquery.wikibase.wbtooltip.js on lines 174..183

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

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                      if ( mw.user.isAnon() ) {
                          mw.cookie.set( cookieKey, copyRightVersion, { expires: 3 * 365 * 24 * 60 * 60, path: '/' } );
                      } else {
                          var api = new mw.Api();
                          api.saveOption( optionsKey, copyRightVersion );
      Severity: Major
      Found in repo/resources/wikibase.ui.entityViewInit.js and 2 other locations - About 2 hrs to fix
      repo/resources/wikibase.federatedPropertiesLeavingSiteNotice.js on lines 58..63
      repo/resources/wikibase.ui.entityViewInit.js on lines 315..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 92.

      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

              _evaluateGravity: function ( gravity ) {
                  if ( document.documentElement.dir === 'rtl' ) {
                      if ( gravity.search( /e/ ) !== -1 ) {
                          gravity = gravity.replace( /e/g, 'w' );
                      } else {
      view/resources/jquery/wikibase/jquery.wikibase.wbtooltip.js on lines 172..181

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

      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.ui.ooMenu.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      ( function () {
          'use strict';
      
          /**
           * jQuery.ui.ooMenu provides an object-oriented menu structure. Menu items are managed using
      Severity: Minor
      Found in client/resources/jquery.ui/jquery.ui.ooMenu.js - About 2 hrs to fix

        File EntityUsageTable.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare( strict_types = 1 );
        
        namespace Wikibase\Client\Usage\Sql;
        Severity: Minor
        Found in client/includes/Usage/Sql/EntityUsageTable.php - About 2 hrs to fix

          Method getForm has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getForm( EntityDocument $entity = null ) {
                  if ( $this->page === null ) {
                      $this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
                  }
                  if ( !$this->badges ) {
          Severity: Major
          Found in repo/includes/Specials/SpecialSetSiteLink.php - About 2 hrs to fix

            File templates.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Wikibase;
            
            /**
            Severity: Minor
            Found in view/resources/templates.php - About 2 hrs to fix

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

                  public function loadEntity( array $requestParams, ?EntityId $entityId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
                      if ( !in_array( $assignFreshId, [ self::ASSIGN_FRESH_ID, self::NO_FRESH_ID ] ) ) {
                          throw new InvalidArgumentException(
                              '$assignFreshId must be either of the EntitySavingHelper::ASSIGN_FRESH_ID/NO_FRESH_ID constants.'
                          );
              Severity: Minor
              Found in repo/includes/Api/EntitySavingHelper.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 resolveTermInLangIds has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function resolveTermInLangIds(
                      array $termInLangIds,
                      array $types = null,
                      array $languages = null
                  ): array {
              Severity: Minor
              Found in lib/includes/Store/Sql/Terms/InMemoryTermStore.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 getLocalizedYear has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getLocalizedYear( $isoTimestamp, $precision ) {
                      preg_match( '/^(\D*)(\d*)/', $isoTimestamp, $matches );
                      [ , $sign, $year ] = $matches;
                      $isBCE = $sign === '-';
              
              
              Severity: Minor
              Found in lib/includes/Formatters/MwTimeIsoFormatter.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 getFormatter has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getFormatter( $dataValueType, $dataTypeId = null ): ValueFormatter {
                      $formatter = null;
              
                      if ( $dataTypeId !== null ) {
                          if ( isset( $this->formatters["PT:$dataTypeId"] ) ) {
              Severity: Minor
              Found in lib/includes/Formatters/DispatchingValueFormatter.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

              Severity
              Category
              Status
              Source
              Language