wikimedia/mediawiki-extensions-Translate

View on GitHub
src/PageTranslation/PageTranslationSpecialPage.php

Summary

Maintainability
F
1 wk
Test Coverage

File PageTranslationSpecialPage.php has 1046 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\PageTranslation;

Severity: Major
Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 days to fix

    Method showPage has 186 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function showPage( TranslatablePageMarkOperation $operation ): void {
            $page = $operation->getPage();
            $out = $this->getOutput();
            $out->addWikiMsg( 'tpt-showpage-intro' );
    
    
    Severity: Major
    Found in src/PageTranslation/PageTranslationSpecialPage.php - About 7 hrs to fix

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

          public function execute( $parameters ) {
              $this->setHeaders();
      
              $user = $this->getUser();
              $request = $this->getRequest();
      Severity: Major
      Found in src/PageTranslation/PageTranslationSpecialPage.php - About 4 hrs to fix

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

            public function execute( $parameters ) {
                $this->setHeaders();
        
                $user = $this->getUser();
                $request = $this->getRequest();
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 4 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

        Function showPage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            private function showPage( TranslatablePageMarkOperation $operation ): void {
                $page = $operation->getPage();
                $out = $this->getOutput();
                $out->addWikiMsg( 'tpt-showpage-intro' );
        
        
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 3 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 showTranslationSettings has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showTranslationSettings( Title $target, ?ErrorPageError $block ): void {
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'tpt-translation-settings-page-title' )->text() );
        
                $currentState = $this->translatablePageStateStore->get( $target );
        Severity: Major
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 3 hrs to fix

          PageTranslationSpecialPage has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class PageTranslationSpecialPage extends SpecialPage {
              private const DISPLAY_STATUS_MAPPING = [
                  TranslatablePageStatus::PROPOSED => 'proposed',
                  TranslatablePageStatus::ACTIVE => 'active',
                  TranslatablePageStatus::OUTDATED => 'outdated',
          Severity: Minor
          Found in src/PageTranslation/PageTranslationSpecialPage.php - About 3 hrs to fix

            Method onActionMark has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function onActionMark( Title $title, ?int $revision ): void {
                    $request = $this->getRequest();
                    $out = $this->getOutput();
                    $translateTitle = $request->getCheck( 'translatetitle' );
            
            
            Severity: Major
            Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

              Method actionLinks has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function actionLinks( array $page, string $type ): string {
                      // Performance optimization to avoid calling $this->msg in a loop
                      static $messageCache = null;
                      if ( $messageCache === null ) {
                          $messageCache = [
              Severity: Major
              Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

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

                    public function listPages(): void {
                        $out = $this->getOutput();
                
                        $res = self::loadPagesFromDB();
                        $allPages = self::buildPageArray( $res );
                Severity: Major
                Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

                  Function onActionMark has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function onActionMark( Title $title, ?int $revision ): void {
                          $request = $this->getRequest();
                          $out = $this->getOutput();
                          $translateTitle = $request->getCheck( 'translatetitle' );
                  
                  
                  Severity: Minor
                  Found in src/PageTranslation/PageTranslationSpecialPage.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 priorityLanguagesForm has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function priorityLanguagesForm( TranslatablePage $page ): void {
                          $groupId = $page->getMessageGroupId();
                          $interfaceLanguage = $this->getLanguage()->getCode();
                          $storedLanguages = (string)$this->messageGroupMetadata->get( $groupId, 'prioritylangs' );
                          $default = $storedLanguages !== '' ? explode( ',', $storedLanguages ) : [];
                  Severity: Minor
                  Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr to fix

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

                        public function listPages(): void {
                            $out = $this->getOutput();
                    
                            $res = self::loadPagesFromDB();
                            $allPages = self::buildPageArray( $res );
                    Severity: Minor
                    Found in src/PageTranslation/PageTranslationSpecialPage.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 getPageList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getPageList( array $pages, string $type ): string {
                            $items = [];
                            $tagsTextCache = [];
                    
                            $tagDiscouraged = $this->msg( 'tpt-tag-discouraged' )->escaped();
                    Severity: Minor
                    Found in src/PageTranslation/PageTranslationSpecialPage.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 classifyPages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function classifyPages( array $pages ): array {
                            $out = [
                                // The ideal state for pages: marked and up to date
                                'active' => [],
                                'proposed' => [],
                    Severity: Minor
                    Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr to fix

                      Method getPageList has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function getPageList( array $pages, string $type ): string {
                              $items = [];
                              $tagsTextCache = [];
                      
                              $tagDiscouraged = $this->msg( 'tpt-tag-discouraged' )->escaped();
                      Severity: Minor
                      Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr to fix

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

                            private function actionLinks( array $page, string $type ): string {
                                // Performance optimization to avoid calling $this->msg in a loop
                                static $messageCache = null;
                                if ( $messageCache === null ) {
                                    $messageCache = [
                        Severity: Minor
                        Found in src/PageTranslation/PageTranslationSpecialPage.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 __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                LanguageFactory $languageFactory,
                                LinkBatchFactory $linkBatchFactory,
                                JobQueueGroup $jobQueueGroup,
                                PermissionManager $permissionManager,
                                TranslatablePageMarker $translatablePageMarker,
                        Severity: Major
                        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr to fix

                          Avoid too many return statements within this method.
                          Open

                                      return;
                          Severity: Major
                          Found in src/PageTranslation/PageTranslationSpecialPage.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return;
                            Severity: Major
                            Found in src/PageTranslation/PageTranslationSpecialPage.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return;
                              Severity: Major
                              Found in src/PageTranslation/PageTranslationSpecialPage.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return;
                                Severity: Major
                                Found in src/PageTranslation/PageTranslationSpecialPage.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return;
                                  Severity: Major
                                  Found in src/PageTranslation/PageTranslationSpecialPage.php - About 30 mins to fix

                                    Function classifyPages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        private function classifyPages( array $pages ): array {
                                            $out = [
                                                // The ideal state for pages: marked and up to date
                                                'active' => [],
                                                'proposed' => [],
                                    Severity: Minor
                                    Found in src/PageTranslation/PageTranslationSpecialPage.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

                                    Function displayStateInfoMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        private function displayStateInfoMessage( Title $title, TranslatableBundleState $bundleState ): void {
                                            $stateId = $bundleState->getStateId();
                                            if ( $stateId === TranslatableBundleState::UNSTABLE ) {
                                                $infoMessage = $this->msg( 'tpt-translation-settings-unstable-notice' );
                                            } elseif ( $stateId === TranslatableBundleState::PROPOSE ) {
                                    Severity: Minor
                                    Found in src/PageTranslation/PageTranslationSpecialPage.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