wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Method assertValidStatements has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function assertValidStatements( array $serialization, Item $originalItem, array $originalStatementsSerialization ): void {
        $validationError = $this->statementsValidator->validateModifiedStatements(
            $originalStatementsSerialization,
            $originalItem->getStatements(),
            $serialization['statements'] ?? [],

    File jquery.wikibase.badgeselector.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @license GPL-2.0-or-later
     * @author H. Snater < mediawiki@snater.com >
     */
    ( function () {
    Severity: Minor
    Found in view/resources/jquery/wikibase/jquery.wikibase.badgeselector.js - About 2 hrs to fix

      RdfBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class RdfBuilder implements EntityRdfBuilder, EntityStubRdfBuilder, EntityMentionListener {
      
          /**
           * A list of entities mentioned/touched to or by this builder.
           * The prefixed entity IDs are used as keys in the array, the value 'true'
      Severity: Minor
      Found in repo/includes/Rdf/RdfBuilder.php - About 2 hrs to fix

        EntityContent has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class EntityContent extends AbstractContent {
        
            /**
             * Flag for use with EntityHandler::validateSave(), indicating that no pre-save validation should be applied.
             * Can be passed in via EditEntity::attemptSave, EntityStore::saveEntity,
        Severity: Minor
        Found in repo/includes/Content/EntityContent.php - About 2 hrs to fix

          WikibaseValueFormatterBuilders has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class WikibaseValueFormatterBuilders {
          
              /**
               * @var FormatterLabelDescriptionLookupFactory
               */
          Severity: Minor
          Found in lib/includes/Formatters/WikibaseValueFormatterBuilders.php - About 2 hrs to fix

            StatementList has 23 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class StatementList implements IteratorAggregate, Countable {
            
                /**
                 * @var Statement[]
                 */
            Severity: Minor
            Found in lib/packages/wikibase/data-model/src/Statement/StatementList.php - About 2 hrs to fix

              Fingerprint has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Fingerprint implements LabelsProvider, DescriptionsProvider, AliasesProvider {
              
                  /**
                   * @deprecated since 2.5, use new Fingerprint() instead.
                   *
              Severity: Minor
              Found in lib/packages/wikibase/data-model/src/Term/Fingerprint.php - About 2 hrs to fix

                Method mergeChanges has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function mergeChanges( EntityId $entityId, array $changes ) {
                        if ( count( $changes ) === 1 ) {
                            return reset( $changes );
                        }
                
                
                Severity: Major
                Found in client/includes/Changes/ChangeRunCoalescer.php - About 2 hrs to fix

                  Method getEntityRevision has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getEntityRevision( EntityId $id, $revision, $allowRedirects = false ) {
                          $prefixedId = $id->getSerialization();
                          $redirectRevision = null;
                  
                          try {
                  Severity: Major
                  Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 2 hrs to fix

                    Function draw has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            draw: function () {
                                var self = this,
                                    deferred = $.Deferred(),
                                    languageCode = this.options.value.getLanguageCode(),
                                    labelText = this.options.value.getText();
                    Severity: Major
                    Found in view/resources/jquery/wikibase/jquery.wikibase.labelview.js - About 2 hrs to fix

                      Method internalDoHtmlPageLinkRendererEnd has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function internalDoHtmlPageLinkRendererEnd(
                              LinkRenderer $linkRenderer,
                              Title $target,
                              &$text,
                              array &$customAttribs,
                      Severity: Major
                      Found in repo/includes/Hooks/HtmlPageLinkRendererEndHookHandler.php - About 2 hrs to fix

                        Function createServices has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export default function createServices(
                            mwWindow: MwWindow,
                            editTags: readonly string[],
                            eventTracker: Tracker,
                        ): ServiceContainer {
                        Severity: Major
                        Found in client/data-bridge/src/services/createServices.ts - About 2 hrs to fix

                          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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language