fossasia/engelsystem

View on GitHub
includes/model/Shifts_model.php

Summary

Maintainability
D
1 day
Test Coverage

Showing 6 of 6 total issues

Function Shift_signup_allowed has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_shifts = null) {
global $user, $privileges;
 
if ($user_shifts == null) {
$user_shifts = Shifts_by_user($user);
Severity: Minor
Found in includes/model/Shifts_model.php - About 2 hrs to fix

Function Shifts_filtered has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function Shifts_filtered() {
global $_REQUEST;
$filter = "";
 
// filterRoom (Array of integer) - Array of Room IDs (optional, for list request)
Severity: Minor
Found in includes/model/Shifts_model.php - About 1 hr to fix

Method Shift_signup_allowed has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_shifts = null) {
global $user, $privileges;
 
if ($user_shifts == null) {
$user_shifts = Shifts_by_user($user);
Severity: Minor
Found in includes/model/Shifts_model.php - About 1 hr to fix

    Function Shift_collides has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function Shift_collides($shift, $shifts) {
    foreach ($shifts as $other_shift)
    if ($shift['SID'] != $other_shift['SID'])
    if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start']))
    return true;
    Severity: Minor
    Found in includes/model/Shifts_model.php - About 35 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    return sql_query("UPDATE `Shifts` SET
    `shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
    `start`='" . sql_escape($shift['start']) . "',
    `end`='" . sql_escape($shift['end']) . "',
    `RID`='" . sql_escape($shift['RID']) . "',
    Severity: Major
    Found in includes/model/Shifts_model.php and 1 other location - About 3 hrs to fix
    includes/model/Shifts_model.php on lines 141..150

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    $result = sql_query("INSERT INTO `Shifts` SET
    `shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
    `start`='" . sql_escape($shift['start']) . "',
    `end`='" . sql_escape($shift['end']) . "',
    `RID`='" . sql_escape($shift['RID']) . "',
    Severity: Major
    Found in includes/model/Shifts_model.php and 1 other location - About 3 hrs to fix
    includes/model/Shifts_model.php on lines 108..117
    Category
    Status