wikimedia/mediawiki-extensions-Translate

View on GitHub
src/PageTranslation/Hooks.php

Summary

Maintainability
F
1 wk
Test Coverage

File Hooks.php has 1201 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\Extension\Translate\PageTranslation;

use Article;
Severity: Major
Found in src/PageTranslation/Hooks.php - About 3 days to fix

    Hooks has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Hooks {
        private const PAGEPROP_HAS_LANGUAGES_TAG = 'translate-has-languages-tag';
        /** @var bool Uuugly hacks */
        public static $allowTargetEdit = false;
        /** State flag used by DeleteTranslatableBundleJob for performance optimizations. */
    Severity: Minor
    Found in src/PageTranslation/Hooks.php - About 5 hrs to fix

      Method languages has 107 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function languages( $data, $params, $parser ) {
              global $wgPageTranslationLanguageList;
      
              if ( $wgPageTranslationLanguageList === 'sidebar-only' ) {
                  return '';
      Severity: Major
      Found in src/PageTranslation/Hooks.php - About 4 hrs to fix

        Function onGetUserPermissionsErrorsExpensive has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function onGetUserPermissionsErrorsExpensive(
                Title $title,
                User $user,
                $action,
                &$result
        Severity: Minor
        Found in src/PageTranslation/Hooks.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 replaceSubtitle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function replaceSubtitle( &$subpages, ?Skin $skin, OutputPage $out ) {
                $linker = MediaWikiServices::getInstance()->getLinkRenderer();
        
                $isTranslationPage = TranslatablePage::isTranslationPage( $out->getTitle() );
                if ( !$isTranslationPage
        Severity: Minor
        Found in src/PageTranslation/Hooks.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 onGetUserPermissionsErrorsExpensive has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function onGetUserPermissionsErrorsExpensive(
                Title $title,
                User $user,
                $action,
                &$result
        Severity: Major
        Found in src/PageTranslation/Hooks.php - About 2 hrs to fix

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

              public static function addLanguageLinks( Title $title, array &$languageLinks ) {
                  global $wgPageTranslationLanguageList;
          
                  if ( $wgPageTranslationLanguageList === 'tag-only' ) {
                      return;
          Severity: Major
          Found in src/PageTranslation/Hooks.php - About 2 hrs to fix

            Method renderTagPage has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function renderTagPage( $wikitextParser, &$text, $state ): void {
                    if ( $text === null ) {
                        // SMW is unhelpfully sending null text if the source contains section tags. Do not explode.
                        return;
                    }
            Severity: Major
            Found in src/PageTranslation/Hooks.php - About 2 hrs to fix

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

                  private static function translationPageHeader( IContextSource $context, TranslatablePage $page ) {
                      global $wgTranslateKeepOutdatedTranslations;
              
                      $title = $context->getTitle();
                      if ( !$title->exists() ) {
              Severity: Major
              Found in src/PageTranslation/Hooks.php - About 2 hrs to fix

                Method replaceSubtitle has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function replaceSubtitle( &$subpages, ?Skin $skin, OutputPage $out ) {
                        $linker = MediaWikiServices::getInstance()->getLinkRenderer();
                
                        $isTranslationPage = TranslatablePage::isTranslationPage( $out->getTitle() );
                        if ( !$isTranslationPage
                Severity: Minor
                Found in src/PageTranslation/Hooks.php - About 1 hr to fix

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

                      public static function onMovePageTranslationUnits(
                          LinkTarget $oldLinkTarget,
                          LinkTarget $newLinkTarget,
                          UserIdentity $userIdentity,
                          int $oldid,
                  Severity: Minor
                  Found in src/PageTranslation/Hooks.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 fetchTranslatableTemplateAndTitle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function fetchTranslatableTemplateAndTitle(
                          ?LinkTarget $contextLink,
                          ?LinkTarget $templateLink,
                          bool &$skip,
                          ?RevisionRecord &$revRecord
                  Severity: Minor
                  Found in src/PageTranslation/Hooks.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 onDeleteTranslationUnit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function onDeleteTranslationUnit(
                          WikiPage $unit,
                          User $user,
                          $reason,
                          $id,
                  Severity: Minor
                  Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                    Method fetchTranslatableTemplateAndTitle has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function fetchTranslatableTemplateAndTitle(
                            ?LinkTarget $contextLink,
                            ?LinkTarget $templateLink,
                            bool &$skip,
                            ?RevisionRecord &$revRecord
                    Severity: Minor
                    Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                      Method sourcePageHeader has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static function sourcePageHeader( IContextSource $context ) {
                              $linker = MediaWikiServices::getInstance()->getLinkRenderer();
                      
                              $language = $context->getLanguage();
                              $title = $context->getTitle();
                      Severity: Minor
                      Found in src/PageTranslation/Hooks.php - About 1 hr to fix

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

                            public static function preventDirectEditing( Title $title, User $user, $action, &$result ) {
                                if ( self::$allowTargetEdit ) {
                                    return true;
                                }
                        
                        
                        Severity: Minor
                        Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                          Function languages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function languages( $data, $params, $parser ) {
                                  global $wgPageTranslationLanguageList;
                          
                                  if ( $wgPageTranslationLanguageList === 'sidebar-only' ) {
                                      return '';
                          Severity: Minor
                          Found in src/PageTranslation/Hooks.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 translateTab has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function translateTab( Skin $skin, array &$tabs ) {
                                  $title = $skin->getTitle();
                                  $handle = new MessageHandle( $title );
                                  $code = $handle->getCode();
                                  $page = TranslatablePage::isTranslationPage( $title );
                          Severity: Minor
                          Found in src/PageTranslation/Hooks.php - About 1 hr to fix

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

                                private static function sourcePageHeader( IContextSource $context ) {
                                    $linker = MediaWikiServices::getInstance()->getLinkRenderer();
                            
                                    $language = $context->getLanguage();
                                    $title = $context->getTitle();
                            Severity: Minor
                            Found in src/PageTranslation/Hooks.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 addLanguageLinks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public static function addLanguageLinks( Title $title, array &$languageLinks ) {
                                    global $wgPageTranslationLanguageList;
                            
                                    if ( $wgPageTranslationLanguageList === 'tag-only' ) {
                                        return;
                            Severity: Minor
                            Found in src/PageTranslation/Hooks.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 translatablePageHeader has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function translatablePageHeader( $article, &$outputDone, &$pcache ) {
                                    if ( $article->getOldID() ) {
                                        return;
                                    }
                            
                            
                            Severity: Minor
                            Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                              Method onMovePageTranslationUnits has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function onMovePageTranslationUnits(
                                      LinkTarget $oldLinkTarget,
                                      LinkTarget $newLinkTarget,
                                      UserIdentity $userIdentity,
                                      int $oldid,
                              Severity: Minor
                              Found in src/PageTranslation/Hooks.php - About 1 hr to fix

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

                                    public static function translateTab( Skin $skin, array &$tabs ) {
                                        $title = $skin->getTitle();
                                        $handle = new MessageHandle( $title );
                                        $code = $handle->getCode();
                                        $page = TranslatablePage::isTranslationPage( $title );
                                Severity: Minor
                                Found in src/PageTranslation/Hooks.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 updateTranslationPage has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        TranslatablePage $page,
                                        string $code,
                                        User $user,
                                        int $flags,
                                        string $summary,
                                Severity: Major
                                Found in src/PageTranslation/Hooks.php - About 50 mins to fix

                                  Method onMovePageTranslationUnits has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          LinkTarget $oldLinkTarget,
                                          LinkTarget $newLinkTarget,
                                          UserIdentity $userIdentity,
                                          int $oldid,
                                          int $newid,
                                  Severity: Major
                                  Found in src/PageTranslation/Hooks.php - About 50 mins to fix

                                    Method onSectionSave has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            WikiPage $wikiPage,
                                            User $user,
                                            TextContent $content,
                                            $summary,
                                            $minor,
                                    Severity: Major
                                    Found in src/PageTranslation/Hooks.php - About 50 mins to fix

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

                                              WikiPage $wikiPage,
                                              UserIdentity $userIdentity,
                                              string $summary,
                                              int $flags,
                                              RevisionRecord $revisionRecord,
                                      Severity: Minor
                                      Found in src/PageTranslation/Hooks.php - About 45 mins to fix

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

                                                WikiPage $unit,
                                                User $user,
                                                $reason,
                                                $id,
                                                $content,
                                        Severity: Minor
                                        Found in src/PageTranslation/Hooks.php - About 45 mins to fix

                                          Function getTranslationRestrictions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              private static function getTranslationRestrictions( MessageHandle $handle, $groupId ) {
                                                  global $wgTranslateDocumentationLanguageCode;
                                          
                                                  // Allow adding message documentation even when translation is restricted
                                                  if ( $handle->getCode() === $wgTranslateDocumentationLanguageCode ) {
                                          Severity: Minor
                                          Found in src/PageTranslation/Hooks.php - About 45 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 tpSyntaxCheck has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                                  RenderedRevision $renderedRevision,
                                                  UserIdentity $user,
                                                  CommentStoreComment $summary,
                                                  $flags,
                                                  Status $hookStatus
                                          Severity: Minor
                                          Found in src/PageTranslation/Hooks.php - About 35 mins to fix

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

                                                    Parser $parser,
                                                    array &$variableCache,
                                                    string $magicWordId,
                                                    ?string &$ret,
                                                    PPFrame $frame
                                            Severity: Minor
                                            Found in src/PageTranslation/Hooks.php - About 35 mins to fix

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

                                                  public static function preventDirectEditing( Title $title, User $user, $action, &$result ) {
                                                      if ( self::$allowTargetEdit ) {
                                                          return true;
                                                      }
                                              
                                              
                                              Severity: Minor
                                              Found in src/PageTranslation/Hooks.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 renderTagPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function renderTagPage( $wikitextParser, &$text, $state ): void {
                                                      if ( $text === null ) {
                                                          // SMW is unhelpfully sending null text if the source contains section tags. Do not explode.
                                                          return;
                                                      }
                                              Severity: Minor
                                              Found in src/PageTranslation/Hooks.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 translationPageHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  private static function translationPageHeader( IContextSource $context, TranslatablePage $page ) {
                                                      global $wgTranslateKeepOutdatedTranslations;
                                              
                                                      $title = $context->getTitle();
                                                      if ( !$title->exists() ) {
                                              Severity: Minor
                                              Found in src/PageTranslation/Hooks.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

                                              Avoid too many return statements within this method.
                                              Open

                                                              return [ 'tpt-translation-restricted', $reason ];
                                              Severity: Major
                                              Found in src/PageTranslation/Hooks.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

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

                                                  Avoid too many return statements within this method.
                                                  Open

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

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return [ 'tpt-translation-restricted-no-reason' ];
                                                    Severity: Major
                                                    Found in src/PageTranslation/Hooks.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                  return $error === [];
                                                      Severity: Major
                                                      Found in src/PageTranslation/Hooks.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

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

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

                                                                private static function getTranslatablePageStatus( ?PageReference $pageReference ): ?array {
                                                                    if ( $pageReference === null ) {
                                                                        return null;
                                                                    }
                                                                    $title = Title::newFromPageReference( $pageReference );
                                                            Severity: Minor
                                                            Found in src/PageTranslation/Hooks.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 onDeleteTranslationUnit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public static function onDeleteTranslationUnit(
                                                                    WikiPage $unit,
                                                                    User $user,
                                                                    $reason,
                                                                    $id,
                                                            Severity: Minor
                                                            Found in src/PageTranslation/Hooks.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 onTitleGetEditNotices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public static function onTitleGetEditNotices( Title $title, int $oldid, array &$notices ) {
                                                                    if ( TranslatablePage::isSourcePage( $title ) ) {
                                                                        $msg = wfMessage( 'translate-edit-tag-warning' )->inContentLanguage();
                                                                        if ( !$msg->isDisabled() ) {
                                                                            $notices['translate-tag'] = $msg->parseAsBlock();
                                                            Severity: Minor
                                                            Found in src/PageTranslation/Hooks.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 translatablePageHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public static function translatablePageHeader( $article, &$outputDone, &$pcache ) {
                                                                    if ( $article->getOldID() ) {
                                                                        return;
                                                                    }
                                                            
                                                            
                                                            Severity: Minor
                                                            Found in src/PageTranslation/Hooks.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 onBeforePageDisplay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
                                                                    global $wgTranslatePageTranslationULS;
                                                            
                                                                    $title = $out->getTitle();
                                                                    $isSource = TranslatablePage::isSourcePage( $title );
                                                            Severity: Minor
                                                            Found in src/PageTranslation/Hooks.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