wikimedia/mediawiki-core

View on GitHub
includes/specialpage/AuthManagerSpecialPage.php

Summary

Maintainability
F
3 days
Test Coverage

File AuthManagerSpecialPage.php has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\SpecialPage;

use ErrorPageError;
Severity: Minor
Found in includes/specialpage/AuthManagerSpecialPage.php - About 7 hrs to fix

    AuthManagerSpecialPage has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AuthManagerSpecialPage extends SpecialPage {
        /** @var string[] The list of actions this special page deals with. Subclasses should override
         * this.
         */
        protected static $allowedActions = [
    Severity: Minor
    Found in includes/specialpage/AuthManagerSpecialPage.php - About 4 hrs to fix

      Function trySubmit has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function trySubmit() {
              $status = false;
      
              $form = $this->getAuthForm( $this->authRequests, $this->authAction );
              $form->setSubmitCallback( [ $this, 'handleFormSubmit' ] );
      Severity: Minor
      Found in includes/specialpage/AuthManagerSpecialPage.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 trySubmit has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function trySubmit() {
              $status = false;
      
              $form = $this->getAuthForm( $this->authRequests, $this->authAction );
              $form->setSubmitCallback( [ $this, 'handleFormSubmit' ] );
      Severity: Major
      Found in includes/specialpage/AuthManagerSpecialPage.php - About 2 hrs to fix

        Method performAuthenticationStep has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function performAuthenticationStep( $action, array $requests ) {
                if ( !in_array( $action, static::$allowedActions, true ) ) {
                    throw new InvalidArgumentException( 'invalid action: ' . $action );
                }
        
        
        Severity: Minor
        Found in includes/specialpage/AuthManagerSpecialPage.php - About 1 hr to fix

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

              protected function handleReauthBeforeExecute( $subPage ) {
                  $authManager = $this->getAuthManager();
                  $request = $this->getRequest();
                  $key = 'AuthManagerSpecialPage:reauth:' . $this->getName();
          
          
          Severity: Minor
          Found in includes/specialpage/AuthManagerSpecialPage.php - About 1 hr to fix

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

                protected function handleReauthBeforeExecute( $subPage ) {
                    $authManager = $this->getAuthManager();
                    $request = $this->getRequest();
                    $key = 'AuthManagerSpecialPage:reauth:' . $this->getName();
            
            
            Severity: Minor
            Found in includes/specialpage/AuthManagerSpecialPage.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 mergeDefaultFormDescriptor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                protected static function mergeDefaultFormDescriptor(
                    array $fieldInfo, array $formDescriptor, array $defaultFormDescriptor
                ) {
                    // keep the ordering from $defaultFormDescriptor where there is no explicit weight
                    foreach ( $defaultFormDescriptor as $fieldName => $defaultField ) {
            Severity: Minor
            Found in includes/specialpage/AuthManagerSpecialPage.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 isActionAllowed has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function isActionAllowed( $action ) {
                    $authManager = $this->getAuthManager();
                    if ( !in_array( $action, static::$allowedActions, true ) ) {
                        throw new InvalidArgumentException( 'invalid action: ' . $action );
                    }
            Severity: Minor
            Found in includes/specialpage/AuthManagerSpecialPage.php - About 1 hr to fix

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

                  protected static function mergeDefaultFormDescriptor(
                      array $fieldInfo, array $formDescriptor, array $defaultFormDescriptor
                  ) {
                      // keep the ordering from $defaultFormDescriptor where there is no explicit weight
                      foreach ( $defaultFormDescriptor as $fieldName => $defaultField ) {
              Severity: Minor
              Found in includes/specialpage/AuthManagerSpecialPage.php - About 1 hr to fix

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

                    protected static function mapSingleFieldInfo( $singleFieldInfo, $fieldName ) {
                        $type = self::mapFieldInfoTypeToFormDescriptorType( $singleFieldInfo['type'] );
                        $descriptor = [
                            'type' => $type,
                            // Do not prefix input name with 'wp'. This is important for the redirect flow.
                Severity: Minor
                Found in includes/specialpage/AuthManagerSpecialPage.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

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

                    protected function loadAuth( $subPage, $authAction = null, $reset = false ) {
                        // Do not load if already loaded, to cut down on the number of getAuthenticationRequests
                        // calls. This is important for requests which have hidden information, so any
                        // getAuthenticationRequests call would mean putting data into some cache.
                        if (
                Severity: Minor
                Found in includes/specialpage/AuthManagerSpecialPage.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

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

                    protected function needsSubmitButton( array $requests ) {
                        $customSubmitButtonPresent = false;
                
                        // Secondary and preauth providers always need their data; they will not care what button
                        // is used, so they can be ignored. So can OPTIONAL buttons createdby primary providers;
                Severity: Minor
                Found in includes/specialpage/AuthManagerSpecialPage.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 true;
                Severity: Major
                Found in includes/specialpage/AuthManagerSpecialPage.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return AuthenticationResponse::newPass();
                  Severity: Major
                  Found in includes/specialpage/AuthManagerSpecialPage.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $authManager->continueAccountLink( $requests );
                    Severity: Major
                    Found in includes/specialpage/AuthManagerSpecialPage.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $authManager->beginAccountLink( $this->getUser(), $requests, $returnToUrl );
                      Severity: Major
                      Found in includes/specialpage/AuthManagerSpecialPage.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return AuthenticationResponse::newFail( $status->getMessage() );
                        Severity: Major
                        Found in includes/specialpage/AuthManagerSpecialPage.php - About 30 mins to fix

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

                              protected function addTabIndex( &$formDescriptor ) {
                                  $i = 1;
                                  foreach ( $formDescriptor as &$definition ) {
                                      $class = false;
                                      if ( array_key_exists( 'class', $definition ) ) {
                          Severity: Minor
                          Found in includes/specialpage/AuthManagerSpecialPage.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