wikimedia/mediawiki-extensions-Translate

View on GitHub
src/MessageLoading/MessageIndex.php

Summary

Maintainability
C
1 day
Test Coverage

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

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\MessageLoading;

Severity: Minor
Found in src/MessageLoading/MessageIndex.php - About 3 hrs to fix

    Method rebuild has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function rebuild( float $timestamp = null ): array {
            static $recursion = 0;
    
            if ( $recursion > 0 ) {
                $msg = __METHOD__ . ': trying to recurse - building the index first time?';
    Severity: Major
    Found in src/MessageLoading/MessageIndex.php - About 3 hrs to fix

      Function rebuild has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function rebuild( float $timestamp = null ): array {
              static $recursion = 0;
      
              if ( $recursion > 0 ) {
                  $msg = __METHOD__ . ': trying to recurse - building the index first time?';
      Severity: Minor
      Found in src/MessageLoading/MessageIndex.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 checkAndAdd has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function checkAndAdd( array &$hugeArray, MessageGroup $g, bool $ignore = false ): void {
              $keys = $g->getKeys();
              $id = $g->getId();
              $namespace = $g->getNamespace();
      
      
      Severity: Minor
      Found in src/MessageLoading/MessageIndex.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 getArrayDiff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getArrayDiff( array $old, array $new ): array {
              $values = [];
              $record = static function ( $groups ) use ( &$values ) {
                  foreach ( $groups as $group ) {
                      $values[$group] = true;
      Severity: Minor
      Found in src/MessageLoading/MessageIndex.php - About 1 hr to fix

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

                MessageIndexStore $store,
                WANObjectCache $statusCache,
                JobQueueGroup $jobQueueGroup,
                HookRunner $hookRunner,
                LoggerInterface $logger,
        Severity: Major
        Found in src/MessageLoading/MessageIndex.php - About 1 hr to fix

          Function getArrayDiff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getArrayDiff( array $old, array $new ): array {
                  $values = [];
                  $record = static function ( $groups ) use ( &$values ) {
                      foreach ( $groups as $group ) {
                          $values[$group] = true;
          Severity: Minor
          Found in src/MessageLoading/MessageIndex.php - About 45 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