BotPassword
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class BotPassword {
public const APPID_MAXLENGTH = 32;
/**
Method login
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function login( $username, $password, WebRequest $request ) {
$enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::EnableBotPasswords );
$passwordAttemptThrottle = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::PasswordAttemptThrottle );
File BotPassword.php
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Utility class for bot passwords
*
* This program is free software; you can redistribute it and/or modify
Function login
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function login( $username, $password, WebRequest $request ) {
$enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::EnableBotPasswords );
$passwordAttemptThrottle = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::PasswordAttemptThrottle );
- 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 canonicalizeLoginData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function canonicalizeLoginData( $username, $password ) {
$sep = self::getSeparator();
// the strlen check helps minimize the password information obtainable from timing
if ( strlen( $password ) >= self::PASSWORD_MINLENGTH && str_contains( $username, $sep ) ) {
// the separator is not valid in new usernames but might appear in legacy ones
- 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 self::loginHook( $user, $bp, $performer, Status::newFatal( 'wrongpassword' ) );
Avoid too many return
statements within this method. Open
return self::loginHook( $user, null, $performer, Status::newFatal( $msg ) );
Avoid too many return
statements within this method. Open
return self::loginHook( $user, $bp, $performer,
Status::newFatal( 'botpasswords-restriction-failed' ) );
Avoid too many return
statements within this method. Open
return self::loginHook( $user, $bp, $performer,
Status::newFatal( 'botpasswords-needs-reset', $name, $appId ) );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'botpasswords-locked' );
Avoid too many return
statements within this method. Open
return self::loginHook( $user, $bp, $performer,
// @phan-suppress-next-line PhanUndeclaredMethod
Status::newGood( $provider->newSessionForRequest( $user, $bp, $request ) ) );
Avoid too many return
statements within this method. Open
return self::loginHook( $user, $bp, $performer,
Status::newFatal( 'botpasswords-not-exist', $name, $appId ) );
Function loginHook
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function loginHook( $user, $bp, User $performer, Status $status ) {
$extraData = [
'performer' => $performer
];
if ( $user instanceof User ) {
- 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"