wikimedia/mediawiki-extensions-Translate

View on GitHub
src/TtmServer/SearchTranslationsSpecialPage.php

Summary

Maintainability
F
4 days
Test Coverage

File SearchTranslationsSpecialPage.php has 518 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\TtmServer;

Severity: Major
Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 1 day to fix

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

        public function execute( $subPage ) {
            $this->setHeaders();
            $this->checkPermissions();
    
            $server = $this->ttmServerFactory->getDefaultForQuerying();
    Severity: Major
    Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 7 hrs to fix

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

          public function execute( $subPage ) {
              $this->setHeaders();
              $this->checkPermissions();
      
              $server = $this->ttmServerFactory->getDefaultForQuerying();
      Severity: Minor
      Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 5 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 messageSelector has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function messageSelector(): string {
              $nonDefaults = $this->opts->getChangedValues();
              $output = Html::openElement( 'div', [ 'class' => 'row tux-messagetable-header' ] );
              $output .= Html::openElement( 'div', [ 'class' => 'twelve columns' ] );
              $output .= Html::openElement( 'ul', [ 'class' => 'row tux-message-selector' ] );
      Severity: Major
      Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 2 hrs to fix

        Method showSearch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showSearch(
                string $search,
                string $count,
                string $facets,
                string $results,
        Severity: Minor
        Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 1 hr to fix

          Function makeGroupFacetRows has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function makeGroupFacetRows(
                  array $groups,
                  array $counts,
                  int $level = 0,
                  string $pathString = ''
          Severity: Minor
          Found in src/TtmServer/SearchTranslationsSpecialPage.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 makeGroupFacetRows has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function makeGroupFacetRows(
                  array $groups,
                  array $counts,
                  int $level = 0,
                  string $pathString = ''
          Severity: Minor
          Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 1 hr to fix

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

                private function getSearchInput( string $query ): string {
                    $attribs = [
                        'placeholder' => $this->msg( 'tux-sst-search-ph' )->text(),
                        'class' => 'searchinputbox mw-ui-input',
                        'dir' => $this->getLanguage()->getDir()
            Severity: Minor
            Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 1 hr to fix

              Function messageSelector has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function messageSelector(): string {
                      $nonDefaults = $this->opts->getChangedValues();
                      $output = Html::openElement( 'div', [ 'class' => 'row tux-messagetable-header' ] );
                      $output .= Html::openElement( 'div', [ 'class' => 'twelve columns' ] );
                      $output .= Html::openElement( 'ul', [ 'class' => 'row tux-message-selector' ] );
              Severity: Minor
              Found in src/TtmServer/SearchTranslationsSpecialPage.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

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

                      string $search,
                      string $count,
                      string $facets,
                      string $results,
                      int $total
              Severity: Minor
              Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 35 mins to fix

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

                    private function getLanguages( array $facet ): array {
                        $output = [];
                
                        $nonDefaults = $this->opts->getChangedValues();
                        $selected = $this->opts->getValue( 'language' );
                Severity: Minor
                Found in src/TtmServer/SearchTranslationsSpecialPage.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