File AuthManagerSpecialPage.php
has 495 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MediaWiki\SpecialPage;
use ErrorPageError;
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 = [
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' ] );
- 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 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' ] );
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 );
}
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();
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();
- 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 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 ) {
- 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 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 );
}
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 ) {
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.
- 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 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 (
- 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 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;
- 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 true;
Avoid too many return
statements within this method. Open
return AuthenticationResponse::newPass();
Avoid too many return
statements within this method. Open
return $authManager->continueAccountLink( $requests );
Avoid too many return
statements within this method. Open
return $authManager->beginAccountLink( $this->getUser(), $requests, $returnToUrl );
Avoid too many return
statements within this method. Open
return AuthenticationResponse::newFail( $status->getMessage() );
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 ) ) {
- 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"