wikimedia/mediawiki-extensions-Translate

View on GitHub
src/Statistics/MessageGroupStats.php

Summary

Maintainability
D
2 days
Test Coverage

File MessageGroupStats.php has 429 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\Statistics;

Severity: Minor
Found in src/Statistics/MessageGroupStats.php - About 6 hrs to fix

    MessageGroupStats has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MessageGroupStats {
        /** Name of the database table */
        private const TABLE = 'translate_groupstats';
        /** Cache key for storage of all language stats */
        private const LANGUAGE_STATS_KEY = 'translate-all-language-stats';
    Severity: Minor
    Found in src/Statistics/MessageGroupStats.php - About 3 hrs to fix

      Method queueUpdates has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function queueUpdates( int $flags ): void {
              $mwInstance = MediaWikiServices::getInstance();
              if ( self::$updates === [] || $mwInstance->getReadOnlyMode()->isReadOnly() ) {
                  return;
              }
      Severity: Minor
      Found in src/Statistics/MessageGroupStats.php - About 1 hr to fix

        Method forItemInternal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function forItemInternal(
                array &$stats,
                MessageGroup $group,
                string $languageCode,
                int $flags
        Severity: Minor
        Found in src/Statistics/MessageGroupStats.php - About 1 hr to fix

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

              private static function calculateGroup( MessageGroup $group, string $languageCode ): array {
                  global $wgTranslateDocumentationLanguageCode;
                  // Calculate if missing and store in the db
                  $collection = $group->initCollection( $languageCode );
          
          
          Severity: Minor
          Found in src/Statistics/MessageGroupStats.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 calculateAggregateGroup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function calculateAggregateGroup(
                  array &$stats,
                  AggregateMessageGroup $group,
                  string $code,
                  int $flags
          Severity: Minor
          Found in src/Statistics/MessageGroupStats.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

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

              private static function queueUpdates( int $flags ): void {
                  $mwInstance = MediaWikiServices::getInstance();
                  if ( self::$updates === [] || $mwInstance->getReadOnlyMode()->isReadOnly() ) {
                      return;
                  }
          Severity: Minor
          Found in src/Statistics/MessageGroupStats.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 forItemInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function forItemInternal(
                  array &$stats,
                  MessageGroup $group,
                  string $languageCode,
                  int $flags
          Severity: Minor
          Found in src/Statistics/MessageGroupStats.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