File SpecialUserRights.php
has 783 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Implements Special:Userrights
*
* This program is free software; you can redistribute it and/or modify
Function groupCheckboxes
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
private function groupCheckboxes( $usergroups, $user ) {
$allgroups = $this->userGroupManager->listAllGroups();
$ret = '';
// Get the list of preset expiry times from the system 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
Method groupCheckboxes
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function groupCheckboxes( $usergroups, $user ) {
$allgroups = $this->userGroupManager->listAllGroups();
$ret = '';
// Get the list of preset expiry times from the system message
Method showEditUserGroupsForm
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showEditUserGroupsForm( $user, $groups, $groupMemberships ) {
$list = $membersList = $tempList = $tempMembersList = [];
foreach ( $groupMemberships as $ugm ) {
$linkG = UserGroupMembership::getLinkHTML( $ugm, $this->getContext() );
$linkM = UserGroupMembership::getLinkHTML( $ugm, $this->getContext(), $user->getName() );
Function saveUserGroups
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
protected function saveUserGroups( $reason, $user ) {
if ( $this->userNameUtils->isTemp( $user->getName() ) ) {
return Status::newFatal( 'userrights-no-tempuser' );
}
$allgroups = $this->userGroupManager->listAllGroups();
- 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 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $par ) {
$user = $this->getUser();
$request = $this->getRequest();
$session = $request->getSession();
$out = $this->getOutput();
Function fetchUser
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function fetchUser( $username, $writing = true ) {
$parts = explode( $this->getConfig()->get( MainConfigNames::UserrightsInterwikiDelimiter ),
$username );
if ( count( $parts ) < 2 ) {
$name = trim( $username );
- 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 23 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $par ) {
$user = $this->getUser();
$request = $this->getRequest();
$session = $request->getSession();
$out = $this->getOutput();
- 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
SpecialUserRights
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class SpecialUserRights extends SpecialPage {
/**
* The target of the local right-adjuster's interest. Can be gotten from
* either a GET parameter or a subpage-style parameter, so have a member
* variable for it.
Method doSaveUserGroups
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doSaveUserGroups( $user, array $add, array $remove, $reason = '',
array $tags = [], array $groupExpiries = []
) {
// Validate input set...
$isself = $user->getName() == $this->getUser()->getName();
Function doSaveUserGroups
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function doSaveUserGroups( $user, array $add, array $remove, $reason = '',
array $tags = [], array $groupExpiries = []
) {
// Validate input set...
$isself = $user->getName() == $this->getUser()->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
Method fetchUser
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchUser( $username, $writing = true ) {
$parts = explode( $this->getConfig()->get( MainConfigNames::UserrightsInterwikiDelimiter ),
$username );
if ( count( $parts ) < 2 ) {
$name = trim( $username );
Method saveUserGroups
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function saveUserGroups( $reason, $user ) {
if ( $this->userNameUtils->isTemp( $user->getName() ) ) {
return Status::newFatal( 'userrights-no-tempuser' );
}
$allgroups = $this->userGroupManager->listAllGroups();
Function showEditUserGroupsForm
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function showEditUserGroupsForm( $user, $groups, $groupMemberships ) {
$list = $membersList = $tempList = $tempMembersList = [];
foreach ( $groupMemberships as $ugm ) {
$linkG = UserGroupMembership::getLinkHTML( $ugm, $this->getContext() );
$linkM = UserGroupMembership::getLinkHTML( $ugm, $this->getContext(), $user->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
Method switchForm
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function switchForm() {
$this->getOutput()->addModules( 'mediawiki.userSuggest' );
$this->getOutput()->addHTML(
Html::openElement(
Method addLogEntry
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function addLogEntry( $user, array $oldGroups, array $newGroups, $reason,
array $tags, array $oldUGMs, array $newUGMs
Method doSaveUserGroups
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function doSaveUserGroups( $user, array $add, array $remove, $reason = '',
array $tags = [], array $groupExpiries = []
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
UserGroupManagerFactory $userGroupManagerFactory = null,
UserNameUtils $userNameUtils = null,
UserNamePrefixSearch $userNamePrefixSearch = null,
UserFactory $userFactory = null,
ActorStoreFactory $actorStoreFactory = null,
Function userCanChangeRights
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function userCanChangeRights( UserIdentity $targetUser, $checkIfSelf = true ) {
$isself = $this->getUser()->equals( $targetUser );
$userGroupManager = $this->userGroupManagerFactory
->getUserGroupManager( $targetUser->getWikiId() );
- 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 Status::newGood();
Avoid too many return
statements within this method. Open
return Status::newFatal( 'nosuchusershort', $username );
Avoid too many return
statements within this method. Open
return Status::newGood( $user );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'userrights-no-group' );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'nosuchusershort', $username );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'nosuchusershort', $username );