jhuesser/bzu-jodel-clone

View on GitHub
functions/admintools.php

Summary

Maintainability
C
1 day
Test Coverage

Showing 8 of 8 total issues

Method reportContent has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function reportContent( $content, $contentID, $reason){
global $apiroot;
$userid = $_SESSION['userid'];
if($content == "post"){
$postfields = "{\n \n \"abuseIDFK\": \"$reason\",\n \"jodelDFK\": \"$contentID\"\n,\n \"jodlerIDFK\": \"$userid\"\n}";
Severity: Minor
Found in functions/admintools.php - About 1 hr to fix

Function getAccountType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getAccountType($config, $acctype){
//init array
$usertype = (object) array();
switch($acctype){
case 0:
Severity: Minor
Found in functions/admintools.php - About 25 mins to fix

Function reportContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function reportContent( $content, $contentID, $reason){
global $apiroot;
$userid = $_SESSION['userid'];
if($content == "post"){
$postfields = "{\n \n \"abuseIDFK\": \"$reason\",\n \"jodelDFK\": \"$contentID\"\n,\n \"jodlerIDFK\": \"$userid\"\n}";
Severity: Minor
Found in functions/admintools.php - About 25 mins to fix

Avoid using undefined variables such as '$config' which will lead to PHP notices.
Open

$newscore = $score - $config->postmeta['get_report'];
Severity: Minor
Found in functions/admintools.php by phpmd

Avoid using undefined variables such as '$config' which will lead to PHP notices.
Open

$newscore = $score - $config->postmeta['get_report'];
Severity: Minor
Found in functions/admintools.php by phpmd

Avoid unused local variables such as '$scoreupdate'.
Open

$scoreupdate = putCall($callurl, $putfields);
Severity: Minor
Found in functions/admintools.php by phpmd

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

} elseif($content == "comment"){
$postfields = "{\n \n \"abuseIDFK\": \"$reason\",\n \"commentIDFK\": \"$contentID\"\n,\n \"jodlerIDFK\": \"$userid\"\n}";
$callurl = $apiroot . "comments?filter=commentID,eq," . $contentID . "&transform=1";
$commentjson = getCall($callurl);
$scores = json_decode($commentjson, true);
Severity: Major
Found in functions/admintools.php and 1 other location - About 3 hrs to fix
functions/admintools.php on lines 59..84

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

if($content == "post"){
$postfields = "{\n \n \"abuseIDFK\": \"$reason\",\n \"jodelDFK\": \"$contentID\"\n,\n \"jodlerIDFK\": \"$userid\"\n}";
$callurl = $apiroot . "jodels?filter=jodelID,eq," . $contentID . "&transform=1";
$jodeljson = getCall($callurl);
$scores = json_decode($jodeljson, true);
Severity: Major
Found in functions/admintools.php and 1 other location - About 3 hrs to fix
functions/admintools.php on lines 72..84
Category
Status