Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Code Quality

on:
push:
branches: [main, development, feature/**, bugfix/**, hotfix/**]
pull_request:
branches: [main, beta, development]

Expand Down
3 changes: 3 additions & 0 deletions .license-overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@fortawesome/free-solid-svg-icons": "License is (CC-BY-4.0 AND MIT) — both are approved open-source licenses, compound AND expression not parsed by checker"
}
51 changes: 11 additions & 40 deletions lib/Controller/AangebodenGebruikController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public function __construct(
* @NoCSRFRequired
* @PublicPage
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function getGebruiksWhereAfnemer(): JSONResponse
{
Expand All @@ -108,10 +106,8 @@ public function getGebruiksWhereAfnemer(): JSONResponse
$result = $this->gebruikSvc->getGebruiksWhereAfnemer($options);

// Determine HTTP status code based on whether there's an error.
if (isset($result['error']) === true) {
$statusCode = 500;
} else {
$statusCode = 200;
if (isset($result['error']) === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -164,8 +160,6 @@ public function getGebruiksWhereAfnemer(): JSONResponse
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
{
Expand Down Expand Up @@ -202,10 +196,8 @@ public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
);

// Determine HTTP status code based on whether there's an error.
if (isset($result['error']) === true) {
$statusCode = 500;
} else {
$statusCode = 200;
if (isset($result['error']) === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -258,8 +250,6 @@ public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function getAllGebruiksForAmbtenaar(): JSONResponse
{
Expand All @@ -278,11 +268,9 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
$isAmbtenaar = $this->isUserInGroup(groupName: 'ambtenaar');
if ($isAdmin === false && $isAmbtenaar === false) {
// Get user ID for logging (may be null if not authenticated).
$user = $this->userSession->getUser();
if ($user !== null) {
$userId = $user->getUID();
} else {
$user = $this->userSession->getUser();
$userId = 'null';
if ($user !== null) {
}

$this->logger->info(
Expand Down Expand Up @@ -315,10 +303,8 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
$result = $this->gebruikSvc->getAllGebruiksForAmbtenaar($options);

// Determine HTTP status code based on whether there's an error.
if (isset($result['error']) === true) {
$statusCode = 500;
} else {
$statusCode = 200;
if (isset($result['error']) === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -370,7 +356,6 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
* @PublicPage
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
Expand All @@ -391,11 +376,9 @@ public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
$isAmbtenaar = $this->isUserInGroup(groupName: 'ambtenaar');
if ($isAdmin === false && $isAmbtenaar === false) {
// Get user ID for logging (may be null if not authenticated).
$user = $this->userSession->getUser();
if ($user !== null) {
$userId = $user->getUID();
} else {
$user = $this->userSession->getUser();
$userId = 'null';
if ($user !== null) {
}

$this->logger->info(
Expand Down Expand Up @@ -432,10 +415,8 @@ public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
);

// Determine HTTP status code based on whether there's an error.
if (isset($result['error']) === true) {
$statusCode = 500;
} else {
$statusCode = 200;
if (isset($result['error']) === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -548,8 +529,6 @@ private function isUserInGroup(string $groupName): bool
* @NoCSRFRequired
* @PublicPage
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function getGebruiksWhereDeelnemers(): JSONResponse
{
Expand All @@ -571,10 +550,8 @@ public function getGebruiksWhereDeelnemers(): JSONResponse
$result = $this->gebruikSvc->getGebruiksWhereDeelnemers($options);

// Determine appropriate HTTP status code.
if ($result['success'] === true) {
$statusCode = 200;
} else {
$statusCode = 500;
if ($result['success'] === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -625,8 +602,6 @@ public function getGebruiksWhereDeelnemers(): JSONResponse
* @NoCSRFRequired
* @PublicPage
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function setGebruikSelfToActiveOrg(string $gebruikId): JSONResponse
{
Expand Down Expand Up @@ -673,14 +648,13 @@ function ($key) {
);

// Determine appropriate HTTP status code.
$statusCode = 500;
if ($result['success'] === true) {
$statusCode = 200;
} else if ($result['error'] === 'Gebruik object not found') {
$statusCode = 404;
} else if (strpos(haystack: ($result['error'] ?? ''), needle: 'Operation not allowed') !== false) {
$statusCode = 403;
} else {
$statusCode = 500;
}

$this->logger->info(
Expand Down Expand Up @@ -735,8 +709,6 @@ function ($key) {
* @NoCSRFRequired
* @PublicPage
* @PublicPage
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function deleteGebruikAsAfnemer(string $gebruikId): JSONResponse
{
Expand Down Expand Up @@ -783,14 +755,13 @@ function ($key) {
);

// Determine appropriate HTTP status code.
$statusCode = 500;
if ($result['success'] === true) {
$statusCode = 200;
} else if ($result['error'] === 'Gebruik object not found') {
$statusCode = 404;
} else if (strpos(haystack: ($result['error'] ?? ''), needle: 'Operation not allowed') !== false) {
$statusCode = 403;
} else {
$statusCode = 500;
}

$this->logger->info(
Expand Down
47 changes: 18 additions & 29 deletions lib/Controller/ContactpersonenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ function ($group) {
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function convertToUser(string $contactpersoonId): JSONResponse
{
Expand Down Expand Up @@ -402,11 +401,9 @@ public function convertToUser(string $contactpersoonId): JSONResponse
$contactpersoonObject->setObject($contactData);

// Debug logging to understand data types before save.
$achternaamValue = $contactData['achternaam'] ?? 'not set';
if (isset($contactData['achternaam']) === true) {
$achternaamType = gettype($contactData['achternaam']);
} else {
$achternaamValue = $contactData['achternaam'] ?? 'not set';
$achternaamType = 'not set';
if (isset($contactData['achternaam']) === true) {
}

$this->logger->info(
Expand Down Expand Up @@ -580,7 +577,6 @@ public function changePassword(string $username, string $newPassword): JSONRespo
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function updateUserGroups(string $username, array $groups=[]): JSONResponse
{
Expand Down Expand Up @@ -633,25 +629,26 @@ public function updateUserGroups(string $username, array $groups=[]): JSONRespon
$groupsToAdd = array_diff($validGroups, $curCatalogGroups);
foreach ($groupsToAdd as $groupName) {
$group = $this->groupManager->get($groupName);
if ($group !== null) {
if ($group->inGroup($user) === false) {
$group->addUser($user);
$this->logger->info(
'Added user to group',
[
'username' => $username,
'group' => $groupName,
]
);
}
} else {
if ($group === null) {
$this->logger->warning(
'Group does not exist, skipping',
[
'username' => $username,
'group' => $groupName,
]
);
continue;
}

if ($group->inGroup($user) === false) {
$group->addUser($user);
$this->logger->info(
'Added user to group',
[
'username' => $username,
'group' => $groupName,
]
);
}
}//end foreach

Expand Down Expand Up @@ -1076,28 +1073,20 @@ public function enableUser(string $contactpersoonId): JSONResponse
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function testBulkUserInfo(): JSONResponse
{
try {
if ($this->contactSvc !== null) {
$objectServiceAvail = 'available';
} else {
$objectServiceAvail = 'null';
if ($this->contactSvc !== null) {
}

if ($this->userManager !== null) {
$userManagerAvail = 'available';
} else {
$userManagerAvail = 'null';
if ($this->userManager !== null) {
}

if ($this->groupManager !== null) {
$groupManagerAvail = 'available';
} else {
$groupManagerAvail = 'null';
if ($this->groupManager !== null) {
}

$this->logger->info(
Expand Down
Loading
Loading