wikimedia/mediawiki-extensions-Translate

View on GitHub
src/TranslatorInterface/TranslateSpecialPage.php

Summary

Maintainability
D
2 days
Test Coverage

File TranslateSpecialPage.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\TranslatorInterface;

Severity: Minor
Found in src/TranslatorInterface/TranslateSpecialPage.php - About 4 hrs to fix

    Function setup has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        private function setup( ?string $parameters ): void {
            $request = $this->getRequest();
    
            $defaults = [
                'language' => $this->getLanguage()->getCode(),
    Severity: Minor
    Found in src/TranslatorInterface/TranslateSpecialPage.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 tabify has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function tabify( Skin $skin, array &$tabs ): bool {
            $title = $skin->getTitle();
            if ( !$title->isSpecialPage() ) {
                return true;
            }
    Severity: Major
    Found in src/TranslatorInterface/TranslateSpecialPage.php - About 2 hrs to fix

      Method messageSelector has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function messageSelector(): string {
              $output = Html::openElement( 'div', [ 'class' => 'row tux-messagetable-header hide' ] );
              $output .= Html::openElement( 'div', [ 'class' => 'nine columns' ] );
              $output .= Html::openElement( 'ul', [ 'class' => 'row tux-message-selector' ] );
              $userId = $this->getUser()->getId();
      Severity: Major
      Found in src/TranslatorInterface/TranslateSpecialPage.php - About 2 hrs to fix

        Method setup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function setup( ?string $parameters ): void {
                $request = $this->getRequest();
        
                $defaults = [
                    'language' => $this->getLanguage()->getCode(),
        Severity: Major
        Found in src/TranslatorInterface/TranslateSpecialPage.php - About 2 hrs to fix

          Method tuxLanguageSelector has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function tuxLanguageSelector(): string {
                  if ( $this->options['language'] === $this->getConfig()->get( 'TranslateDocumentationLanguageCode' ) ) {
                      $targetLangName = $this->msg( 'translate-documentation-language' )->text();
                      $targetLanguage = $this->contentLanguage;
                  } else {
          Severity: Minor
          Found in src/TranslatorInterface/TranslateSpecialPage.php - About 1 hr to fix

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

                public static function tabify( Skin $skin, array &$tabs ): bool {
                    $title = $skin->getTitle();
                    if ( !$title->isSpecialPage() ) {
                        return true;
                    }
            Severity: Minor
            Found in src/TranslatorInterface/TranslateSpecialPage.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 execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function execute( $parameters ) {
                    $out = $this->getOutput();
                    $out->addModuleStyles( [
                        'ext.translate.special.translate.styles',
                        'jquery.uls.grid',
            Severity: Minor
            Found in src/TranslatorInterface/TranslateSpecialPage.php - About 1 hr to fix

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

                      Language $contentLanguage,
                      LanguageFactory $languageFactory,
                      LanguageNameUtils $languageNameUtils,
                      HookRunner $hookRunner,
                      Config $config
              Severity: Minor
              Found in src/TranslatorInterface/TranslateSpecialPage.php - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status