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
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
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
- Read upRead up
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;
- Read upRead up
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;
LoginSignupSpecialPage
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
protected $mReturnTo;
protected $mPosted;
protected $mAction;
protected $mLanguage;
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() ) {
Method load
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function load( $subPage ) {
$this->loadRequestParameters();
if ( $this->mLoaded ) {
return;
}
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() : '';
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;
}
- Read upRead up
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?
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;
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() ) {
- Read upRead up
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'] ) &&
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'] ) &&
- Read upRead up
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();
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;
- Read upRead up
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
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() : '';
- Read upRead up
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?
- Read upRead up
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;
}
- Read upRead up
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' );
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $fieldDefinitions;
Avoid too many return
statements within this method. Open
return $this->msg( 'changeemail-maxlength' );
Avoid too many return
statements within this method. Open
return $this->msg( 'invalidemailaddress' );
Avoid too many return
statements within this method. Open
return $this->reasonValidatorResult;
Avoid too many return
statements within this method. Open
return $this->reasonValidatorResult;
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',
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;