wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/Api/ResultBuilder.php

Summary

Maintainability
F
3 days
Test Coverage

File ResultBuilder.php has 647 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Wikibase\Repo\Api;

use MediaWiki\Api\ApiResult;
Severity: Major
Found in repo/includes/Api/ResultBuilder.php - About 1 day to fix

    ResultBuilder has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ResultBuilder {
    
        /**
         * @var ApiResult
         */
    Severity: Minor
    Found in repo/includes/Api/ResultBuilder.php - About 5 hrs to fix

      Function filterEntitySerializationUsingLangCodes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          private function filterEntitySerializationUsingLangCodes(
              array $serialization,
              array $langCodes
          ) {
              if ( $langCodes ) {
      Severity: Minor
      Found in repo/includes/Api/ResultBuilder.php - About 4 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 getTermsSerializationWithFallbackInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getTermsSerializationWithFallbackInfo(
              array $serialization,
              array $termFallbackChains
          ) {
              $newSerialization = $serialization;
      Severity: Minor
      Found in repo/includes/Api/ResultBuilder.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

      Method getEntitySerializationWithMetaData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getEntitySerializationWithMetaData( array $serialization ) {
              $serializeEmptyListsAsObjects = WikibaseRepo::getSettings()->getSetting( 'tmpSerializeEmptyListsAsObjects' );
              $modifications = [];
      
              $makeIdKvpCallback = $this->callbackFactory->getCallbackToSetArrayType( 'kvp', 'id' );
      Severity: Minor
      Found in repo/includes/Api/ResultBuilder.php - About 1 hr to fix

        Method addEntityRevision has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addEntityRevision(
                $sourceEntityIdSerialization,
                EntityRevision $entityRevision,
                $props = 'all',
                array $filterSiteIds = null,
        Severity: Minor
        Found in repo/includes/Api/ResultBuilder.php - About 1 hr to fix

          Function filterEntitySerializationUsingProps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function filterEntitySerializationUsingProps( array $serialization, $props ) {
                  if ( $props !== 'all' ) {
                      if ( !in_array( 'labels', $props ) ) {
                          unset( $serialization['labels'] );
                      }
          Severity: Minor
          Found in repo/includes/Api/ResultBuilder.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

          Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  ApiResult $result,
                  EntityTitleStoreLookup $entityTitleStoreLookup,
                  SerializerFactory $serializerFactory,
                  Serializer $entitySerializer,
                  SiteLookup $siteLookup,
          Severity: Major
          Found in repo/includes/Api/ResultBuilder.php - About 1 hr to fix

            Function addEntityRevision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addEntityRevision(
                    $sourceEntityIdSerialization,
                    EntityRevision $entityRevision,
                    $props = 'all',
                    array $filterSiteIds = null,
            Severity: Minor
            Found in repo/includes/Api/ResultBuilder.php - About 55 mins 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

            Method addEntityRevision has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $sourceEntityIdSerialization,
                    EntityRevision $entityRevision,
                    $props = 'all',
                    array $filterSiteIds = null,
                    array $filterLangCodes = [],
            Severity: Minor
            Found in repo/includes/Api/ResultBuilder.php - About 45 mins to fix

              Method getModifiedEntityArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      EntityDocument $entity,
                      $props,
                      ?array $filterSiteIds,
                      array $filterLangCodes,
                      array $termFallbackChains
              Severity: Minor
              Found in repo/includes/Api/ResultBuilder.php - About 35 mins to fix

                Function filterEntitySerializationUsingSiteIds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function filterEntitySerializationUsingSiteIds(
                        array $serialization,
                        array $siteIds = null
                    ) {
                        if ( $siteIds && array_key_exists( 'sitelinks', $serialization ) ) {
                Severity: Minor
                Found in repo/includes/Api/ResultBuilder.php - About 35 mins 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 addRevisionIdFromStatusToResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function addRevisionIdFromStatusToResult( Status $status, $path, $oldRevId = null ) {
                        $value = $status->getValue();
                
                        if ( isset( $value['revision'] ) ) {
                            if ( $value['revision'] instanceof EntityRevision ) {
                Severity: Minor
                Found in repo/includes/Api/ResultBuilder.php - About 35 mins 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

                There are no issues that match your filters.

                Category
                Status