wikimedia/mediawiki-extensions-Translate

View on GitHub
src/Statistics/LanguageStatsSpecialPage.php

Summary

Maintainability
D
2 days
Test Coverage

File LanguageStatsSpecialPage.php has 346 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/LanguageStatsSpecialPage.php - About 4 hrs to fix

    Function execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute( $par ) {
            $this->target = $this->getLanguage()->getCode();
            $request = $this->getRequest();
    
            $this->purge = $request->getVal( 'action' ) === 'purge';
    Severity: Minor
    Found in src/Statistics/LanguageStatsSpecialPage.php - About 2 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

    Method execute has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute( $par ) {
            $this->target = $this->getLanguage()->getCode();
            $request = $this->getRequest();
    
            $this->purge = $request->getVal( 'action' ) === 'purge';
    Severity: Major
    Found in src/Statistics/LanguageStatsSpecialPage.php - About 2 hrs to fix

      Method makeGroupRow has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function makeGroupRow(
              MessageGroup $group,
              array $cache,
              MessageGroup $parent = null,
              int $depth = 0
      Severity: Major
      Found in src/Statistics/LanguageStatsSpecialPage.php - About 2 hrs to fix

        Method addForm has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function addForm(): void {
                $formDescriptor = [
                    'language' => [
                        'type' => 'text',
                        'name' => 'language',
        Severity: Minor
        Found in src/Statistics/LanguageStatsSpecialPage.php - About 1 hr to fix

          Method getTable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getTable( array $stats ): string {
                  $table = $this->table;
                  $out = '';
          
                  // This avoids a database query per translatable page, which would be caused by
          Severity: Minor
          Found in src/Statistics/LanguageStatsSpecialPage.php - About 1 hr to fix

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

                    LinkBatchFactory $linkBatchFactory,
                    ProgressStatsTableFactory $progressStatsTableFactory,
                    LanguageNameUtils $languageNameUtils,
                    JobQueueGroup $jobQueueGroup,
                    MessageGroupReviewStore $groupReviewStore,
            Severity: Minor
            Found in src/Statistics/LanguageStatsSpecialPage.php - About 45 mins to fix

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

                  private function getTable( array $stats ): string {
                      $table = $this->table;
                      $out = '';
              
                      // This avoids a database query per translatable page, which would be caused by
              Severity: Minor
              Found in src/Statistics/LanguageStatsSpecialPage.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 makeGroupRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function makeGroupRow(
                      MessageGroup $group,
                      array $cache,
                      MessageGroup $parent = null,
                      int $depth = 0
              Severity: Minor
              Found in src/Statistics/LanguageStatsSpecialPage.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