wikimedia/mediawiki-extensions-Wikibase

View on GitHub
client/includes/Usage/ImplicitDescriptionUsageLookup.php

Summary

Maintainability
C
7 hrs
Test Coverage

Function findImplicitUsages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function findImplicitUsages( array $entityIds ): array {
        $numericItemIds = [];
        foreach ( $entityIds as $entityId ) {
            if ( $entityId instanceof ItemId ) {
                $numericItemIds[] = $entityId->getNumericId();
Severity: Minor
Found in client/includes/Usage/ImplicitDescriptionUsageLookup.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 findImplicitUsages has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function findImplicitUsages( array $entityIds ): array {
        $numericItemIds = [];
        foreach ( $entityIds as $entityId ) {
            if ( $entityId instanceof ItemId ) {
                $numericItemIds[] = $entityId->getNumericId();
Severity: Minor
Found in client/includes/Usage/ImplicitDescriptionUsageLookup.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

      Function filterImplicitUsages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          private function filterImplicitUsages(
              array $itemIdsByPageId,
              array $contentLanguagesByPageId,
              array $aspects
          ): array {
      Severity: Minor
      Found in client/includes/Usage/ImplicitDescriptionUsageLookup.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 getUsagesForPage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getUsagesForPage( int $pageId ): array {
              $usages = $this->usageLookup->getUsagesForPage( $pageId );
              $title = $this->titleFactory->newFromID( $pageId );
              if ( !$title ) {
                  return $usages;
      Severity: Minor
      Found in client/includes/Usage/ImplicitDescriptionUsageLookup.php - About 1 hr to fix

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

                UsageLookup $usageLookup,
                TitleFactory $titleFactory,
                bool $allowLocalShortDesc,
                DescriptionLookup $descriptionLookup,
                LinkBatchFactory $linkBatchFactory,
        Severity: Major
        Found in client/includes/Usage/ImplicitDescriptionUsageLookup.php - About 50 mins to fix

          There are no issues that match your filters.

          Category
          Status