Function setMembership
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
public function setMembership(int $userId, string $startDate, string $endDate, ?bool $leader = null, bool $forcePeriod = false)
{
global $gCurrentUser, $gCurrentUserId, $gCurrentSession;
$newMembershipSaved = false;
- 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
File TableRoles.php
has 504 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
use Admidio\Exception;
/**
* @brief Class manages access to database table adm_roles
Method setMembership
has 130 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setMembership(int $userId, string $startDate, string $endDate, ?bool $leader = null, bool $forcePeriod = false)
{
global $gCurrentUser, $gCurrentUserId, $gCurrentSession;
$newMembershipSaved = false;
Function setValue
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function setValue(string $columnName, $newValue, bool $checkValue = true): bool
{
global $gL10n, $gCurrentUser;
if ($checkValue) {
- 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
TableRoles
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class TableRoles extends TableAccess
{
public const ROLE_GROUP = 0;
public const ROLE_EVENT = 1;
Method setValue
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setValue(string $columnName, $newValue, bool $checkValue = true): bool
{
global $gL10n, $gCurrentUser;
if ($checkValue) {
Method delete
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete(): bool
{
global $gCurrentSession, $gL10n;
$rolId = (int)$this->getValue('rol_id');
Consider simplifying this complex logical expression. Open
if ($startDate < $row['mem_end'] && $endDate >= $row['mem_end']) {
// new period starts in existing period and ends after existing period
if ($leader === (bool)$row['mem_leader']) {
$newMembershipSaved = true;
Function allowedToAssignMembers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function allowedToAssignMembers(User $user): bool
{
// you aren't allowed to change membership of not active roles
if ((int)$this->getValue('rol_valid') === 0) {
return false;
- 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 setMembership
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setMembership(int $userId, string $startDate, string $endDate, ?bool $leader = null, bool $forcePeriod = false)
Function delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function delete(): bool
{
global $gCurrentSession, $gL10n;
$rolId = (int)$this->getValue('rol_id');
- 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"