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 deserializeQualifiers( array $serialization, string $basePath ): SnakList {
        $qualifiers = [];
        foreach ( $serialization['qualifiers'] as $index => $qualifier ) {
            if ( !is_array( $qualifier ) ) {
                throw new InvalidFieldException( "$index", $qualifier, "$basePath/qualifiers/$index" );
repo/rest-api/src/Application/Serialization/StatementDeserializer.php on lines 81..91

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

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

    private function formatSnaks( array $snaks ) {
        $formattedValues = [];

        foreach ( $snaks as $snak ) {
            $formattedValue = $this->snakFormatter->formatSnak( $snak );
client/includes/DataAccess/Scribunto/SnakSerializationRenderer.php on lines 89..109

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

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

    private function formatSnakList( array $snaks ) {
        $formattedValues = [];

        foreach ( $snaks as $snak ) {
            $formattedValue = $this->snakFormatter->formatSnak( $snak );
client/includes/DataAccess/StatementTransclusionInteractor.php on lines 130..150

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

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

    private function deserializeReferences( array $serialization, string $basePath ): ReferenceList {
        $references = [];
        foreach ( $serialization['references'] as $index => $reference ) {
            if ( !is_array( $reference ) ) {
                throw new InvalidFieldException( "$index", $reference, "$basePath/references/$index" );
repo/rest-api/src/Application/Serialization/StatementDeserializer.php on lines 69..79

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

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

    protected function createSummary( EntityDocument $property ) {
        $uiLanguageCode = $this->getLanguage()->getCode();

        $summary = new Summary( 'wbeditentity', 'create' );
        $summary->setLanguage( $uiLanguageCode );
Severity: Major
Found in repo/includes/Specials/SpecialNewProperty.php and 1 other location - About 1 hr to fix
repo/includes/Specials/SpecialNewItem.php on lines 415..430

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

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

    protected function createSummary( EntityDocument $item ): Summary {
        $uiLanguageCode = $this->getLanguage()->getCode();

        $summary = new Summary( 'wbeditentity', 'create' );
        $summary->setLanguage( $uiLanguageCode );
Severity: Major
Found in repo/includes/Specials/SpecialNewItem.php and 1 other location - About 1 hr to fix
repo/includes/Specials/SpecialNewProperty.php on lines 323..338

Duplicated Code

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

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

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

Tuning

This issue has a mass of 105.

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

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

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

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

Refactorings

Further Reading

Function getStatementView has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    SELF.prototype.getStatementView = function ( startEditingCallback, entityId, propertyId, removeCallback, value, $dom ) {
        var currentPropertyId = value ? value.getClaim().getMainSnak().getPropertyId() : propertyId;
        var view = this._getView(
            'statementview',
            $dom,
Severity: Minor
Found in view/resources/wikibase/view/ViewFactory.js - About 1 hr to fix

    Function getStatementView has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        SELF.prototype.getStatementView = function ( startEditingCallback, entityId, propertyId, removeCallback, value, $dom ) {
            var controller;
            var startEditingController = function () {
                return controller.startEditing();
            };
    Severity: Minor
    Found in view/resources/wikibase/view/ControllerViewFactory.js - About 1 hr to fix

      Function _onConfirmationDataLoad has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _onConfirmationDataLoad: function ( entity ) {
                  var i, itemLink;
      
                  if ( entity && entity.sitelinks ) {
                      var siteLinkCount = 0;
      Severity: Minor
      Found in client/resources/jquery.wikibase/jquery.wikibase.linkitem.js - About 1 hr to fix

        Function search has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                search: function () {
                    var self = this,
                        deferred = $.Deferred();
        
                    this._clearTimeout();
        Severity: Minor
        Found in client/resources/jquery.ui/jquery.ui.suggester.js - About 1 hr to fix

          Function ae93 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          /***/ (function(module, exports, __webpack_require__) {
          
          "use strict";
          
          var fails = __webpack_require__("d039");
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

            Method doQuery has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function doQuery( array $params, ApiPageSet $resultPageSet = null ): ?IResultWrapper {
                    if ( !$params['entities'] ) {
                        return null;
                    }
            
            
            Severity: Minor
            Found in client/includes/Api/ApiListEntityUsage.php - About 1 hr to fix

              Method getPageHeader has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPageHeader() {
                      $excludeNamespaces = array_diff(
                          $this->namespaceInfo->getValidNamespaces(),
                          $this->namespaceChecker->getWikibaseNamespaces()
                      );
              Severity: Minor
              Found in client/includes/Specials/SpecialUnconnectedPages.php - About 1 hr to fix

                Method formatEntityUsage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function formatEntityUsage( array $usages, IContextSource $context ): array {
                        $usageAspectsByEntity = [];
                        $entityIds = [];
                
                        foreach ( $usages as $entityUsage ) {
                Severity: Minor
                Found in client/includes/Hooks/InfoActionHookHandler.php - About 1 hr to fix

                  Method getPagesUsing has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getPagesUsing( array $entityIds, array $aspects = [] ): Traversable {
                          if ( !$this->aspectsMatchImplicitUsage( $aspects ) ) {
                              // Caller is not interested in implicit usage,
                              // no need to add anything
                              return yield from $this->usageLookup->getPagesUsing( $entityIds, $aspects );
                  Severity: Minor
                  Found in client/includes/Usage/ImplicitDescriptionUsageLookup.php - About 1 hr to fix

                    Method attemptSave has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function attemptSave(
                            Title $title,
                            EntityContent $content,
                            string $summary,
                            int $undidRevId,
                    Severity: Minor
                    Found in repo/includes/Actions/SubmitEntityAction.php - About 1 hr to fix

                      Method getAllowedParams has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function getAllowedParams(): array {
                              return array_merge(
                                  [
                                      'claim' => [
                                          ParamValidator::PARAM_TYPE => 'string',
                      Severity: Minor
                      Found in repo/includes/Api/SetClaimValue.php - About 1 hr to fix

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

                            public function execute(): void {
                                $params = $this->extractRequestParams();
                                $result = $this->getResult();
                        
                                $context = $params['context'];
                        Severity: Minor
                        Found in repo/includes/Api/MetaContentLanguages.php - About 1 hr to fix

                          Method getAllowedParams has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function getAllowedParams(): array {
                                  return array_merge( [
                                      'fromid' => [
                                          ParamValidator::PARAM_TYPE => 'string',
                                          ParamValidator::PARAM_REQUIRED => true,
                          Severity: Minor
                          Found in repo/includes/Api/MergeItems.php - About 1 hr to fix

                            Method rdfSerialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function rdfSerialize(
                                    EntityRevision $entityRevision,
                                    ?RedirectRevision $followedRedirect,
                                    array $incomingRedirects,
                                    RdfBuilder $rdfBuilder,
                            Severity: Minor
                            Found in repo/includes/LinkedData/EntityDataSerializationService.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language