wikimedia/mediawiki-extensions-MobileFrontend

View on GitHub
includes/MobileFrontendHooks.php

Summary

Maintainability
F
4 days
Test Coverage

File MobileFrontendHooks.php has 697 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName

use MediaWiki\Actions\ActionEntryPoint;
Severity: Major
Found in includes/MobileFrontendHooks.php - About 1 day to fix

    MobileFrontendHooks has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MobileFrontendHooks implements
        APIQuerySiteInfoGeneralInfoHook,
        AuthChangeFormFieldsHook,
        RequestContextCreateSkinHook,
        BeforeDisplayNoArticleTextHook,
    Severity: Minor
    Found in includes/MobileFrontendHooks.php - About 6 hrs to fix

      Method onBeforePageDisplay has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function onBeforePageDisplay( $out, $skin ): void {
              $context = $this->mobileContext;
              $mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
              $mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
              $isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
      Severity: Major
      Found in includes/MobileFrontendHooks.php - About 3 hrs to fix

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

            public function onBeforePageDisplay( $out, $skin ): void {
                $context = $this->mobileContext;
                $mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
                $mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
                $isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
        Severity: Minor
        Found in includes/MobileFrontendHooks.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 onOutputPageBeforeHTML has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function onOutputPageBeforeHTML( $out, &$text ) {
                // This hook can be executed more than once per page view if the page content is composed from
                // multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
        
                $context = $this->mobileContext;
        Severity: Minor
        Found in includes/MobileFrontendHooks.php - About 1 hr to fix

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

              public function onRequestContextCreateSkin( $context, &$skin ) {
                  $mobileContext = $this->mobileContext;
          
                  $mobileContext->doToggling();
                  if ( !$mobileContext->shouldDisplayMobileView() ) {
          Severity: Minor
          Found in includes/MobileFrontendHooks.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 onRequestContextCreateSkin has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function onRequestContextCreateSkin( $context, &$skin ) {
                  $mobileContext = $this->mobileContext;
          
                  $mobileContext->doToggling();
                  if ( !$mobileContext->shouldDisplayMobileView() ) {
          Severity: Minor
          Found in includes/MobileFrontendHooks.php - About 1 hr to fix

            Method getResourceLoaderMFConfigVars has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getResourceLoaderMFConfigVars() {
                    $vars = [];
                    $config = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Config' );
                    $mfScriptPath = $config->get( 'MFScriptPath' );
                    $pageProps = $config->get( 'MFQueryPropModules' );
            Severity: Minor
            Found in includes/MobileFrontendHooks.php - About 1 hr to fix

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

                      HookContainer $hookContainer,
                      Config $config,
                      SkinFactory $skinFactory,
                      UserOptionsLookup $userOptionsLookup,
                      WatchlistManager $watchlistManager,
              Severity: Major
              Found in includes/MobileFrontendHooks.php - About 1 hr to fix

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

                    public function onMediaWikiPerformAction( $output, $article, $title, $user,
                        $request, $entryPoint
                Severity: Minor
                Found in includes/MobileFrontendHooks.php - About 45 mins to fix

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

                      public function onOutputPageBeforeHTML( $out, &$text ) {
                          // This hook can be executed more than once per page view if the page content is composed from
                          // multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
                  
                          $context = $this->mobileContext;
                  Severity: Minor
                  Found in includes/MobileFrontendHooks.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 onSkinAddFooterLinks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerLinks ) {
                          $context = $this->mobileContext;
                          if ( $key === 'places' ) {
                              if ( $context->shouldDisplayMobileView() ) {
                                  $terms = MobileFrontendSkinHooks::getTermsLink( $skin );
                  Severity: Minor
                  Found in includes/MobileFrontendHooks.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 hasEditNoticesFeatureConflict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function hasEditNoticesFeatureConflict( Config $config, User $user ): bool {
                          $gadgetName = $config->get( 'MFEditNoticesConflictingGadgetName' );
                          if ( !$gadgetName ) {
                              return false;
                          }
                  Severity: Minor
                  Found in includes/MobileFrontendHooks.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 onSpecialPageBeforeExecute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function onSpecialPageBeforeExecute( $special, $subpage ) {
                          $isMobileView = $this->mobileContext->shouldDisplayMobileView();
                          $taglines = $this->mobileContext->getConfig()->get( 'MFSpecialPageTaglines' );
                          $name = $special->getName();
                  
                  
                  Severity: Minor
                  Found in includes/MobileFrontendHooks.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 onPostLoginRedirect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function onPostLoginRedirect( &$returnTo, &$returnToQuery, &$type ) {
                          $context = $this->mobileContext;
                  
                          if ( !$context->shouldDisplayMobileView() ) {
                              return;
                  Severity: Minor
                  Found in includes/MobileFrontendHooks.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