wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Method createEntityChangeOp has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createEntityChangeOp( array $changeRequest ) {
        $this->assertArray( $changeRequest['sitelinks'], 'List of sitelinks must be an array' );

        $siteLinksChangeOps = new ChangeOps();
        $sites = $this->siteLinkTargetProvider->getSiteList( $this->siteLinkGroups );

    Method convertToFormattableSummary has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function convertToFormattableSummary( EditSummary $editSummary ): FormatableSummary {
            switch ( true ) {
                case $editSummary instanceof PatchPropertyEditSummary:
                    return $this->wholeEntityEditSummaryConverter->newSummaryForPropertyPatch( $editSummary );
    
    
    Severity: Minor
    Found in repo/rest-api/src/Infrastructure/EditSummaryFormatter.php - About 1 hr to fix

      Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute() {
              if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseRepository' ) ) {
                  $this->fatalError(
                      "You need to have Wikibase enabled in order to use this "
                      . "maintenance script!\n\n",
      Severity: Minor
      Found in repo/maintenance/rebuildItemTerms.php - About 1 hr to fix

        Method validate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function validate(
                ?string $itemId,
                string $siteId,
                array $sitelink,
                string $basePath = ''

          Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function execute() {
                  if ( WikibaseRepo::getSettings()
                       ->getSetting( 'enablePopulateWithRandomEntitiesAndTermsScript' ) !== true
                  ) {
                      $this->output(
          Severity: Minor
          Found in repo/maintenance/populateWithRandomEntitiesAndTerms.php - About 1 hr to fix

            Method throwUseCaseError has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function throwUseCaseError( ValidationError $validationError ): void {
                    $context = $validationError->getContext();
                    switch ( $validationError->getCode() ) {
                        case LanguageCodeValidator::CODE_INVALID_LANGUAGE_CODE:
                            throw UseCaseError::newPatchResultInvalidKey( '', $context[LanguageCodeValidator::CONTEXT_LANGUAGE_CODE] );

              Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function execute( PatchPropertyDescriptionsRequest $request ): PatchPropertyDescriptionsResponse {
                      $deserializedRequest = $this->useCaseValidator->validateAndDeserialize( $request );
                      $propertyId = $deserializedRequest->getPropertyId();
              
                      $this->assertPropertyExists->execute( $propertyId );

                Method format has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function format( $value ) {
                        if ( !( $value instanceof TimeValue ) ) {
                            throw new InvalidArgumentException( 'Data value type mismatch. Expected a TimeValue.' );
                        }
                
                
                Severity: Minor
                Found in lib/includes/Formatters/TimeDetailsFormatter.php - About 1 hr to fix

                  Method toStandardUnits has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function toStandardUnits( UnboundedQuantityValue $value ) {
                          $fromUnit = $value->getUnit();
                  
                          if ( $fromUnit === '1' ) {
                              // Won't convert unitless values
                  Severity: Minor
                  Found in lib/includes/Units/UnitConverter.php - About 1 hr to fix

                    Method saveLinksOfItem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function saveLinksOfItem( Item $item ): bool {
                            //First check whether there's anything to update
                            $newLinks = $item->getSiteLinkList()->toArray();
                            $oldLinks = $this->getSiteLinksForItem( $item->getId() );
                    
                    
                    Severity: Minor
                    Found in lib/includes/Store/Sql/SiteLinkTable.php - About 1 hr to fix

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

                          'WikibaseClient.TermFallbackCacheFactory' => function ( MediaWikiServices $services ): TermFallbackCacheFactory {
                              $settings = WikibaseClient::getSettings( $services );
                              return new TermFallbackCacheFactory(
                                  $settings->getSetting( 'sharedCacheType' ),
                                  WikibaseClient::getLogger( $services ),
                      Severity: Major
                      Found in client/WikibaseClient.ServiceWiring.php and 1 other location - About 1 hr to fix
                      repo/WikibaseRepo.ServiceWiring.php on lines 1947..1958

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

                      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

                          'WikibaseRepo.TermFallbackCacheFactory' => function ( MediaWikiServices $services ): TermFallbackCacheFactory {
                              $settings = WikibaseRepo::getSettings( $services );
                              return new TermFallbackCacheFactory(
                                  $settings->getSetting( 'sharedCacheType' ),
                                  WikibaseRepo::getLogger( $services ),
                      Severity: Major
                      Found in repo/WikibaseRepo.ServiceWiring.php and 1 other location - About 1 hr to fix
                      client/WikibaseClient.ServiceWiring.php on lines 1010..1021

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

                      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 __construct(
                              EntityTitleStoreLookup $titleLookup,
                              EntityRevisionLookup $entityLookup,
                              EntityStore $entityStore,
                              EntityPermissionChecker $permissionChecker,
                      Severity: Major
                      Found in repo/includes/EditEntity/MediaWikiEditEntityFactory.php and 1 other location - About 1 hr to fix
                      repo/includes/ChangeOp/Deserialization/ChangeOpDeserializerFactory.php on lines 95..121

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

                      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 __construct(
                              FingerprintChangeOpFactory $fingerprintChangeOpFactory,
                              StatementChangeOpFactory $statementChangeOpFactory,
                              SiteLinkChangeOpFactory $siteLinkChangeOpFactory,
                              TermChangeOpSerializationValidator $termChangeOpSerializationValidator,
                      repo/includes/EditEntity/MediaWikiEditEntityFactory.php on lines 81..107

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

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

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

                      wikibase.view.termFallbackResolver = ( function ( wb ) {
                          'use strict';
                      
                          var SELF = {};
                      
                      
                      Severity: Minor
                      Found in view/resources/wikibase/view/termFallbackResolver.js - About 1 hr 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 7c73 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      /***/ (function(module, exports, __webpack_require__) {
                      
                      var anObject = __webpack_require__("825a");
                      var defineProperties = __webpack_require__("37e8");
                      var enumBugKeys = __webpack_require__("7839");
                      Severity: Minor
                      Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr 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 getSiteLinkMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getSiteLinkMessage( $action, Diff $siteLinkDiff, Title $title = null ) {
                              if ( $siteLinkDiff->isEmpty() ) {
                                  return null;
                              }
                      
                      
                      Severity: Minor
                      Found in client/includes/RecentChanges/SiteLinkCommentCreator.php - About 1 hr 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 findImplicitUsages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function findImplicitUsages( array $entityIds ): array {
                              $numericItemIds = [];
                              foreach ( $entityIds as $entityId ) {
                                  if ( $entityId instanceof ItemId ) {
                                      $numericItemIds[] = $entityId->getNumericId();
                      Severity: Minor
                      Found in client/includes/Usage/ImplicitDescriptionUsageLookup.php - About 1 hr 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 getEntityIds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function getEntityIds( array $sites, array $titles, $normalize ) {
                              $ids = [];
                              $numSites = count( $sites );
                              $numTitles = count( $titles );
                      
                      
                      Severity: Minor
                      Found in repo/includes/Api/EntityByTitleHelper.php - About 1 hr 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