File Users.php
has 462 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
Function editUser
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public function editUser($parameters) {
/** @var string $targetUserId */
$targetUserId = $parameters['userid'];
// Check if user is logged in
- 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 editUser
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function editUser($parameters) {
/** @var string $targetUserId */
$targetUserId = $parameters['userid'];
// Check if user is logged in
Function addUser
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function addUser() {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
$groups = isset($_POST['groups']) ? $_POST['groups'] : null;
$user = $this->userSession->getUser();
- 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 removeFromGroup
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function removeFromGroup($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
- 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 addUser
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addUser() {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
$groups = isset($_POST['groups']) ? $_POST['groups'] : null;
$user = $this->userSession->getUser();
Method removeFromGroup
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function removeFromGroup($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
Function getUsersGroups
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getUsersGroups($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
- 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 getUsers
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUsers() {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
$offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
Method getUser
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUser($parameters) {
$userId = $parameters['userid'];
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
Method getUsersGroups
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUsersGroups($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
Function getUsers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getUsers() {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
$offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
- 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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
IUserManager $userManager,
IGroupManager $groupManager,
IUserSession $userSession,
ILogger $logger,
IConfig $config,
Function getUser
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getUser($parameters) {
$userId = $parameters['userid'];
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
- 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 addToGroup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addToGroup($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
if ($user === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
- 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 deleteUser
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function deleteUser($parameters) {
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
- 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 getUserSubAdminGroups
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getUserSubAdminGroups($parameters) {
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
return new Result(null, API::RESPOND_UNAUTHORISED);
- 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 new Result(null, 103, 'Unknown error occurred');
Avoid too many return
statements within this method. Open
return new Result(null, 100);
Avoid too many return
statements within this method. Open
return new Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
Avoid too many return
statements within this method. Open
return new Result(null, 100);
Avoid too many return
statements within this method. Open
return new Result(null, 997);
Avoid too many return
statements within this method. Open
return new Result(null, 103);
Avoid too many return
statements within this method. Open
return new Result(null, 101, $e->getMessage());
Avoid too many return
statements within this method. Open
return new Result(null, 105, 'Cannot remove yourself from the admin group');
Avoid too many return
statements within this method. Open
return new Result(null, 102);
Avoid too many return
statements within this method. Open
return new Result(null, 103);
Avoid too many return
statements within this method. Open
return new Result(null, 100);
Avoid too many return
statements within this method. Open
return new Result(null, 403, $e->getMessage());
Avoid too many return
statements within this method. Open
return new Result(null, 100);
Avoid too many return
statements within this method. Open
return new Result(null, 106, 'no group specified (required for subadmins)');
Avoid too many return
statements within this method. Open
return new Result(null, 103, 'Unknown error occurred');
Avoid too many return
statements within this method. Open
return new Result(null, 103, "Invalid quota value {$parameters['_put']['value']}");
Avoid too many return
statements within this method. Open
return new Result(null, 104);
Avoid too many return
statements within this method. Open
return new Result(null, 100);
Avoid too many return
statements within this method. Open
return new Result(null, 101);
Function addSubAdmin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addSubAdmin($parameters) {
$group = $this->groupManager->get($_POST['groupid']);
$user = $this->userManager->get($parameters['userid']);
// Check if the user exists
- 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"