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

<?php declare( strict_types = 1 );

namespace Wikibase\Repo\RestApi\Domain\ReadModel;

use ArrayObject;
Severity: Major
Found in repo/rest-api/src/Domain/ReadModel/Labels.php and 1 other location - About 2 hrs to fix
repo/rest-api/src/Domain/ReadModel/Descriptions.php on lines 1..30

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

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\Domain\ReadModel;

use ArrayObject;
Severity: Major
Found in repo/rest-api/src/Domain/ReadModel/Descriptions.php and 1 other location - About 2 hrs to fix
repo/rest-api/src/Domain/ReadModel/Labels.php on lines 1..30

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

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 EntitySavingHelper.php has 268 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/EntitySavingHelper.php - About 2 hrs to fix

    Function formatResult has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function formatResult(
            IResultWrapper $res,
            int $limit,
            array $prop,
            ?ApiPageSet $resultPageSet
    Severity: Minor
    Found in client/includes/Api/ApiListEntityUsage.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 formatResult has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function formatResult( IResultWrapper $res, int $limit, array $prop ): void {
            $currentPageId = null;
            $entry = [];
            $count = 0;
    
    
    Severity: Minor
    Found in client/includes/Api/ApiPropsEntityUsage.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 buildTermSearchMatchPageEntry has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function buildTermSearchMatchPageEntry( TermSearchResult $match, ?array $props ): array {
            $entityId = $match->getEntityId();
            if ( $entityId !== null ) {
                $entry = [
                    'id' => $entityId->getSerialization(),
    Severity: Minor
    Found in repo/includes/Api/SearchEntities.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 attemptSave has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
            $this->checkReadOnly( $newEntity ); // throws, exception formatted by MediaWiki (cf. MWExceptionRenderer::getExceptionTitle)
            $this->checkEntityId( $newEntity->getId() ); // throws internal error (unexpected condition)
    
            $watch = $this->getDesiredWatchState( $watch );
    Severity: Minor
    Found in repo/includes/EditEntity/MediaWikiEditEntity.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 _initTagEvents has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _initTagEvents: function ( $tag ) {
                var self = this,
                    $input = $tag.find( 'input' );
    
                $input
    Severity: Major
    Found in view/resources/jquery/ui/jquery.ui.tagadata.js - About 2 hrs to fix

      Method onLoadExtensionSchemaUpdates has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function onLoadExtensionSchemaUpdates( $updater ) {
              $db = $updater->getDB();
              $type = $db->getType();
      
              if ( $type !== 'mysql' && $type !== 'sqlite' && $type !== 'postgres' ) {
      Severity: Major
      Found in repo/includes/Store/Sql/DatabaseSchemaUpdater.php - About 2 hrs to fix

        Method handleRequest has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handleRequest( $doc, WebRequest $request, OutputPage $output ) {
                // No matter what: The response is always public
                $output->getRequest()->response()->header( 'Access-Control-Allow-Origin: *' );
        
                $revision = 0;
        Severity: Major
        Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 2 hrs to fix

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

                  degrade: function ( remove ) {
                      var self = this;
          
                      this.element.one( 'wbtooltipafterhide', function ( event ) {
                          self.destroy();
          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 155..166

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

          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

                  degrade: function ( remove ) {
                      var self = this;
          
                      this.element.one( 'wbtooltipafterhide', function ( event ) {
                          self.destroy();
          view/resources/jquery/wikibase/jquery.wikibase.wbtooltip.js on lines 153..164

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

          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

              public function __construct(
                  PropertyLabelResolver $propertyLabelResolver,
                  SnaksFinder $snaksFinder,
                  EntityLookup $entityLookup,
                  DataAccessSnakFormatterFactory $dataAccessSnakFormatterFactory,
          repo/includes/ChangeOp/Deserialization/SiteLinksChangeOpDeserializer.php on lines 76..94
          repo/includes/ParserOutput/PlaceholderExpander/ExternallyRenderedEntityViewPlaceholderExpander.php on lines 50..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 129.

          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

              public function __construct(
                  OutputPage $outputPage,
                  TermboxRequestInspector $requestInspector,
                  TermboxRenderer $termboxRenderer,
                  OutputPageEntityIdReader $entityIdReader,
          client/includes/DataAccess/ParserFunctions/StatementGroupRendererFactory.php on lines 74..92
          repo/includes/ChangeOp/Deserialization/SiteLinksChangeOpDeserializer.php on lines 76..94

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

          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 $propertyId, string $languageCode ): Response {
                  $jsonBody = $this->getValidatedBody();
                  '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
          
                  try {
          repo/rest-api/src/RouteHandlers/SetPropertyLabelRouteHandler.php on lines 79..98

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

          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 $propertyId, string $languageCode ): Response {
                  $jsonBody = $this->getValidatedBody();
                  '@phan-var array $jsonBody'; // guaranteed to be an array per getBodyParamSettings()
                  try {
                      $useCaseResponse = $this->setPropertyLabel->execute(
          repo/rest-api/src/RouteHandlers/AddPropertyAliasesInLanguageRouteHandler.php on lines 81..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 129.

          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

              public function __construct(
                  SiteLinkBadgeChangeOpSerializationValidator $badgeChangeOpSerializationValidator,
                  SiteLinkChangeOpFactory $siteLinkChangeOpFactory,
                  SiteLinkPageNormalizer $siteLinkPageNormalizer,
                  SiteLinkTargetProvider $siteLinkTargetProvider,
          client/includes/DataAccess/ParserFunctions/StatementGroupRendererFactory.php on lines 74..92
          repo/includes/ParserOutput/PlaceholderExpander/ExternallyRenderedEntityViewPlaceholderExpander.php on lines 50..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 129.

          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 SetClaim.php has 266 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/SetClaim.php - About 2 hrs to fix

            Function 69f3 has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            /***/ (function(module, exports, __webpack_require__) {
            
            var NATIVE_WEAK_MAP = __webpack_require__("7f9a");
            var global = __webpack_require__("da84");
            var isObject = __webpack_require__("861d");
            Severity: Major
            Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 2 hrs to fix

              Method undo has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function undo(): void {
                      $request = $this->getRequest();
                      $undidRevId = $request->getInt( 'undo' );
                      $undidAfterRevId = $request->getInt( 'undoafter' );
                      $restoreId = $request->getInt( 'restore' );
              Severity: Major
              Found in repo/includes/Actions/SubmitEntityAction.php - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language