File AbstractTemporaryPasswordPrimaryAuthenticationProvider.php
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Function providerAllowsAuthenticationDataChange
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function providerAllowsAuthenticationDataChange(
AuthenticationRequest $req, $checkData = true
) {
if ( get_class( $req ) !== TemporaryPasswordAuthenticationRequest::class ) {
// We don't really ignore it, but this is what the caller expects.
- 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 providerAllowsAuthenticationDataChange
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function providerAllowsAuthenticationDataChange(
AuthenticationRequest $req, $checkData = true
) {
if ( get_class( $req ) !== TemporaryPasswordAuthenticationRequest::class ) {
// We don't really ignore it, but this is what the caller expects.
Method beginPrimaryAuthentication
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function beginPrimaryAuthentication( array $reqs ) {
$req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class );
if ( !$req || $req->username === null || $req->password === null ) {
return AuthenticationResponse::newAbstain();
}
Method sendPasswordResetEmail
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function sendPasswordResetEmail( TemporaryPasswordAuthenticationRequest $req ): void {
$user = User::newFromName( $req->username );
if ( !$user ) {
return;
}
Function testForAccountCreation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function testForAccountCreation( $user, $creator, array $reqs ) {
/** @var TemporaryPasswordAuthenticationRequest $req */
$req = AuthenticationRequest::getRequestByClass(
$reqs, TemporaryPasswordAuthenticationRequest::class
);
- 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 $sv;
Avoid too many return
statements within this method. Open
return \StatusValue::newFatal( 'passwordreset-nosuchcaller', $req->caller );
Avoid too many return
statements within this method. Open
return $this->failResponse( $req );
Avoid too many return
statements within this method. Open
return AuthenticationResponse::newPass( $username );
Avoid too many return
statements within this method. Open
return \StatusValue::newFatal( 'passwordreset-emaildisabled' );
Avoid too many return
statements within this method. Open
return \StatusValue::newFatal( 'throttled-mailpassword',
round( $this->passwordReminderResendTime, 3 ) );
Avoid too many return
statements within this method. Open
return [];
Avoid too many return
statements within this method. Open
return \StatusValue::newFatal( 'passwordreset-nocaller' );
Avoid too many return
statements within this method. Open
return [ new TemporaryPasswordAuthenticationRequest ];
Function beginPrimaryAuthentication
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function beginPrimaryAuthentication( array $reqs ) {
$req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class );
if ( !$req || $req->username === null || $req->password === null ) {
return AuthenticationResponse::newAbstain();
}
- 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 beginPrimaryAccountCreation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function beginPrimaryAccountCreation( $user, $creator, array $reqs ) {
/** @var TemporaryPasswordAuthenticationRequest $req */
$req = AuthenticationRequest::getRequestByClass(
$reqs, TemporaryPasswordAuthenticationRequest::class
);
- 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"