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 addTermsToSerialization( Property $property, array &$serialization ) {
        $fingerprint = $property->getFingerprint();

        $serialization['labels'] = $this->termListSerializer->serialize( $fingerprint->getLabels() );
        $serialization['descriptions'] =
lib/packages/wikibase/data-model-serialization/src/Serializers/ItemSerializer.php on lines 91..99

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

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

    'WikibaseClient.EntityTypeDefinitions' => function ( MediaWikiServices $services ): EntityTypeDefinitions {
        $baseEntityTypes = require __DIR__ . '/../lib/WikibaseLib.entitytypes.php';
        $clientEntityTypes = require __DIR__ . '/WikibaseClient.entitytypes.php';

        $entityTypes = wfArrayPlus2d(
Severity: Minor
Found in client/WikibaseClient.ServiceWiring.php and 1 other location - About 30 mins to fix
repo/WikibaseRepo.ServiceWiring.php on lines 1094..1106

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

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 getHtmlForTerms( EntityDocument $entity ) {
        $id = $entity->getId();

        if ( $entity instanceof LabelsProvider && $entity instanceof DescriptionsProvider ) {
            return $this->entityTermsView->getHtml(
Severity: Minor
Found in view/src/PropertyView.php and 1 other location - About 30 mins to fix
view/src/ItemView.php on lines 179..193

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

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 newItemTermStoreWriter(): ItemTermStoreWriter {
        if ( !in_array( Item::ENTITY_TYPE, $this->localEntitySource->getEntityTypes() ) ) {
            throw new LogicException( 'Local entity source does not have items.' );
        }

Severity: Minor
Found in lib/includes/Store/Sql/Terms/TermStoreWriterFactory.php and 1 other location - About 30 mins to fix
lib/includes/Store/Sql/Terms/TermStoreWriterFactory.php on lines 101..113

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

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

Avoid too many return statements within this function.
Open

                    return -1;
Severity: Major
Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return new datamodel.Statement(
                    new datamodel.Claim( mainSnak, qualifiers, guid ),
                    references,
                    this._rankSelector.value()
                );
    Severity: Major
    Found in view/resources/jquery/wikibase/jquery.wikibase.statementview.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                              return 0;
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return null;
        Severity: Major
        Found in view/resources/jquery/wikibase/jquery.wikibase.referenceview.js - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return [ $term->getText(), $term->getActualLanguageCode() ];

            Avoid too many return statements within this method.
            Open

                    return null;
            Severity: Major
            Found in client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return [ $term->getText(), $term->getActualLanguageCode() ];

                Avoid too many return statements within this method.
                Open

                                return null;
                Severity: Major
                Found in client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $title->getPrefixedText() === $diffOp->getOldValue() ||
                              $title->getPrefixedText() === $diffOp->getNewValue();
                  Severity: Major
                  Found in client/includes/RecentChanges/SiteLinkCommentCreator.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return array_combine(
                                range( 1, count( $badges ) ), $badges
                            );

                      Avoid too many return statements within this method.
                      Open

                                  return $termFallback->getText();
                      Severity: Major
                      Found in client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return 0;
                        Severity: Major
                        Found in client/includes/Changes/ChangeRunCoalescer.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return Status::newFatal( 'edit_form_incomplete' ); //XXX: better message?
                          Severity: Major
                          Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return Status::newFatal( 'wikibase-undo-badpage', $this->getTitle(), $newerRevision->getId() );
                            Severity: Major
                            Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return $newTitle;
                              Severity: Major
                              Found in client/includes/Hooks/EchoNotificationsHandlers.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return Status::newFatal( 'wikibase-undo-samerev', $this->getTitle() );
                                Severity: Major
                                Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language