wikimedia/mediawiki-core

View on GitHub
includes/specialpage/LoginSignupSpecialPage.php

Summary

Maintainability
F
1 wk
Test Coverage

File LoginSignupSpecialPage.php has 947 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Holds shared logic for login and account creation pages.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/specialpage/LoginSignupSpecialPage.php - About 2 days to fix

    Method getFieldDefinitions has 297 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getFieldDefinitions( array $fieldInfo ) {
            $isLoggedIn = $this->getUser()->isRegistered();
            $continuePart = $this->isContinued() ? 'continue-' : '';
            $anotherPart = $isLoggedIn ? 'another-' : '';
            // @phan-suppress-next-line PhanUndeclaredMethod
    Severity: Major
    Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 day to fix

      Function getFieldDefinitions has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getFieldDefinitions( array $fieldInfo ) {
              $isLoggedIn = $this->getUser()->isRegistered();
              $continuePart = $this->isContinued() ? 'continue-' : '';
              $anotherPart = $isLoggedIn ? 'another-' : '';
              // @phan-suppress-next-line PhanUndeclaredMethod
      Severity: Minor
      Found in includes/specialpage/LoginSignupSpecialPage.php - About 6 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 execute has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute( $subPage ) {
              if ( $this->mPosted ) {
                  $time = microtime( true );
                  $profilingScope = new ScopedCallback( function () use ( $time ) {
                      $time = microtime( true ) - $time;
      Severity: Minor
      Found in includes/specialpage/LoginSignupSpecialPage.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 execute has 130 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute( $subPage ) {
              if ( $this->mPosted ) {
                  $time = microtime( true );
                  $profilingScope = new ScopedCallback( function () use ( $time ) {
                      $time = microtime( true ) - $time;
      Severity: Major
      Found in includes/specialpage/LoginSignupSpecialPage.php - About 5 hrs to fix

        LoginSignupSpecialPage has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
            protected $mReturnTo;
            protected $mPosted;
            protected $mAction;
            protected $mLanguage;
        Severity: Minor
        Found in includes/specialpage/LoginSignupSpecialPage.php - About 3 hrs to fix

          Method getBenefitsContainerHtml has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getBenefitsContainerHtml(): string {
                  $benefitsContainer = '';
                  $this->getOutput()->addModuleStyles( [ 'oojs-ui.styles.icons-user' ] );
                  if ( $this->isSignup() && $this->showExtraInformation() ) {
                      if ( !$this->getUser()->isTemp() ) {
          Severity: Major
          Found in includes/specialpage/LoginSignupSpecialPage.php - About 2 hrs to fix

            Method load has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function load( $subPage ) {
                    $this->loadRequestParameters();
                    if ( $this->mLoaded ) {
                        return;
                    }
            Severity: Major
            Found in includes/specialpage/LoginSignupSpecialPage.php - About 2 hrs to fix

              Method getPageHtml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function getPageHtml( $formHtml ) {
                      $loginPrompt = $this->isSignup() ? '' : Html::rawElement( 'div',
                          [ 'id' => 'userloginprompt' ], $this->msg( 'loginprompt' )->parseAsBlock() );
                      $languageLinks = $this->getConfig()->get( MainConfigNames::LoginLanguageSelector )
                          ? $this->makeLanguageSelector() : '';
              Severity: Minor
              Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 hr to fix

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

                    private function canBypassForm( &$button_name ) {
                        $button_name = null;
                        if ( $this->isContinued() ) {
                            return false;
                        }
                Severity: Minor
                Found in includes/specialpage/LoginSignupSpecialPage.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 mainLoginForm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function mainLoginForm( array $requests, $msg = '', $msgtype = 'error' ) {
                        $user = $this->getUser();
                        $out = $this->getOutput();
                
                        // FIXME how to handle empty $requests - restart, or no form, just an error message?
                Severity: Minor
                Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 hr to fix

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

                      protected function getAuthForm( array $requests, $action ) {
                          // FIXME merge this with parent
                  
                          if ( isset( $this->authForm ) ) {
                              return $this->authForm;
                  Severity: Minor
                  Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 hr to fix

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

                        protected function getBenefitsContainerHtml(): string {
                            $benefitsContainer = '';
                            $this->getOutput()->addModuleStyles( [ 'oojs-ui.styles.icons-user' ] );
                            if ( $this->isSignup() && $this->showExtraInformation() ) {
                                if ( !$this->getUser()->isTemp() ) {
                    Severity: Minor
                    Found in includes/specialpage/LoginSignupSpecialPage.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 postProcessFormDescriptor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function postProcessFormDescriptor( &$formDescriptor, $requests ) {
                            // Pre-fill username (if not creating an account, T46775).
                            if (
                                isset( $formDescriptor['username'] ) &&
                                !isset( $formDescriptor['username']['default'] ) &&
                    Severity: Minor
                    Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 hr to fix

                      Function postProcessFormDescriptor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function postProcessFormDescriptor( &$formDescriptor, $requests ) {
                              // Pre-fill username (if not creating an account, T46775).
                              if (
                                  isset( $formDescriptor['username'] ) &&
                                  !isset( $formDescriptor['username']['default'] ) &&
                      Severity: Minor
                      Found in includes/specialpage/LoginSignupSpecialPage.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

                      Consider simplifying this complex logical expression.
                      Open

                              if ( !$this->isSignup() && !$this->mPosted && !$this->securityLevel &&
                                  ( $this->mReturnTo !== '' || $this->mReturnToQuery !== '' ) &&
                                  !$this->getUser()->isTemp() && $this->getUser()->isRegistered()
                              ) {
                                  $this->successfulAction();
                      Severity: Major
                      Found in includes/specialpage/LoginSignupSpecialPage.php - About 1 hr to fix

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

                            protected function getAuthForm( array $requests, $action ) {
                                // FIXME merge this with parent
                        
                                if ( isset( $this->authForm ) ) {
                                    return $this->authForm;
                        Severity: Minor
                        Found in includes/specialpage/LoginSignupSpecialPage.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 showSuccessPage has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                $type, $title, $msgname, $injected_html, $extraMessages
                        Severity: Minor
                        Found in includes/specialpage/LoginSignupSpecialPage.php - About 35 mins to fix

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

                              protected function getPageHtml( $formHtml ) {
                                  $loginPrompt = $this->isSignup() ? '' : Html::rawElement( 'div',
                                      [ 'id' => 'userloginprompt' ], $this->msg( 'loginprompt' )->parseAsBlock() );
                                  $languageLinks = $this->getConfig()->get( MainConfigNames::LoginLanguageSelector )
                                      ? $this->makeLanguageSelector() : '';
                          Severity: Minor
                          Found in includes/specialpage/LoginSignupSpecialPage.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 mainLoginForm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function mainLoginForm( array $requests, $msg = '', $msgtype = 'error' ) {
                                  $user = $this->getUser();
                                  $out = $this->getOutput();
                          
                                  // FIXME how to handle empty $requests - restart, or no form, just an error message?
                          Severity: Minor
                          Found in includes/specialpage/LoginSignupSpecialPage.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 load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function load( $subPage ) {
                                  $this->loadRequestParameters();
                                  if ( $this->mLoaded ) {
                                      return;
                                  }
                          Severity: Minor
                          Found in includes/specialpage/LoginSignupSpecialPage.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 $this->msg( 'noemailcreate' );
                          Severity: Major
                          Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                    return true;
                            Severity: Major
                            Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return $fieldDefinitions;
                              Severity: Major
                              Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                            return $this->msg( 'changeemail-maxlength' );
                                Severity: Major
                                Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                              return $this->msg( 'invalidemailaddress' );
                                  Severity: Major
                                  Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                                    return $this->reasonValidatorResult;
                                    Severity: Major
                                    Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                                  return $this->reasonValidatorResult;
                                      Severity: Major
                                      Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                return Html::rawElement( 'div',
                                                                    [ 'id' => 'mw-createaccount' . ( !$isLoggedIn ? '-cta' : '' ),
                                                                        'class' => ( $isLoggedIn ? 'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
                                                                    ( $isLoggedIn ? '' : $this->msg( 'userlogin-noaccount' )->escaped() )
                                                                    . Html::element( 'a',
                                        Severity: Major
                                        Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return true;
                                          Severity: Major
                                          Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                    return true;
                                            Severity: Major
                                            Found in includes/specialpage/LoginSignupSpecialPage.php - About 30 mins to fix

                                              There are no issues that match your filters.

                                              Category
                                              Status