wikimedia/mediawiki-extensions-Wikibase

View on GitHub
lib/includes/Store/CachingPrefetchingTermLookup.php

Summary

Maintainability
C
1 day
Test Coverage

File CachingPrefetchingTermLookup.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Lib\Store;
Severity: Minor
Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 3 hrs to fix

    CachingPrefetchingTermLookup has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class CachingPrefetchingTermLookup implements PrefetchingTermLookup {
    
        use TermCacheKeyBuilder;
    
        private const DEFAULT_TTL = 60;
    Severity: Minor
    Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 2 hrs to fix

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

          private function getCacheKeys( array $entityIds, array $termTypes, array $languageCodes ): array {
              $cacheKeys = [];
              $unresolvedIds = [];
              $keyPartsMap = [];
              foreach ( $entityIds as $entityId ) {
      Severity: Minor
      Found in lib/includes/Store/CachingPrefetchingTermLookup.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 getPrefetchedTermsFromLookup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getPrefetchedTermsFromLookup(
              array $entitiesToPrefetch,
              array $languagesToPrefetch,
              array $termTypes
          ): array {
      Severity: Minor
      Found in lib/includes/Store/CachingPrefetchingTermLookup.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 prefetchCachedTerms has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function prefetchCachedTerms( array $entityIds, array $termTypes, array $languageCodes ): array {
              [
                  self::RESOLVED_KEYS => $cacheKeys,
                  self::UNRESOLVED_IDS => $unresolvedIds, // This is intentionally unused.
                  self::KEY_PARTS_MAP => $keyPartsMap,
      Severity: Minor
      Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 1 hr to fix

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

                CacheInterface $cache,
                PrefetchingTermLookup $lookup,
                RedirectResolvingLatestRevisionLookup $redirectResolvingRevisionLookup,
                ContentLanguages $termLanguages,
                ?int $ttl = null
        Severity: Minor
        Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 35 mins to fix

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

              private function getMultipleTermsByLanguageFromLookup( EntityId $entityId, string $termType, array $languages ) {
                  if ( $termType === TermTypes::TYPE_LABEL ) {
                      $freshTerms = $this->lookup->getLabels( $entityId, $languages );
                  } else {
                      $freshTerms = $this->lookup->getDescriptions( $entityId, $languages );
          Severity: Minor
          Found in lib/includes/Store/CachingPrefetchingTermLookup.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 getMultipleTermsByLanguageFromCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getMultipleTermsByLanguageFromCache( EntityId $entityId, string $termType, array $languages ) {
                  $terms = [];
          
                  $languagesToCacheKeys = [];
          
          
          Severity: Minor
          Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 25 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