Showing 1,065 of 16,781 total issues
Avoid deeply nested control flow statements. Open
Open
if ($battery !== '') $this->_result['devices'][$prefix.$details[0]]['battery'] = $battery;
Avoid deeply nested control flow statements. Open
Open
if ($lang == "") {
$lang = 'Unknown';
}
Function execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function execute()
{
$this->_lines = array();
switch (strtolower(PSI_PLUGIN_DOCKER_ACCESS)) {
case 'command':
- 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 deeply nested control flow statements. Open
Open
if ($partition[2]=="ACTIVE") {
if (isset($disksinfo[$partition[1]]["status"])) {
if ($disksinfo[$partition[1]]["status"]!=="ACTIVE") {
$this->_result['devices'][$group]['items'][$partition[1]]['status'] = "W";
} elseif ($disksinfo[$partition[1]]["substatus"]=="ACTIVE") {
Avoid deeply nested control flow statements. Open
Open
if (($data['childs']==1) && ($data['parentid']==-2) && isset($this->_result['devices'][$group]['items'][$id+1]) && !preg_match("/^mirror$|^mirror-|^spare$|^spare-|^replacing$|^replacing-|^raidz[123]$|^raidz[123]-/", $this->_result['devices'][$group]['items'][$id+1]['name'])) {
$this->_result['devices'][$group]['items'][$id]['name2'] = "jbod";
} elseif ($data['childs']>1) {
$this->_result['devices'][$group]['items'][$id]['name2'] = "stripe";
}
Avoid deeply nested control flow statements. Open
Open
if (@exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
define('PSI_UNAMEO', $unameo0);
}
Avoid deeply nested control flow statements. Open
Open
if ($data['parentid']==-2) {
unset($this->_result['devices'][$group]['items'][$id]);
} elseif (($data['parentid'] == -1) && !isset($this->_result['devices'][$group]['items'][$id+1]['type'])) {
$this->_result['devices'][$group]['items'][$id+1]['name2'] = $data['name'];
$this->_result['devices'][$group]['items'][$id+1]['parentid'] = $data['parentid'];
Avoid deeply nested control flow statements. Open
Open
isset($group['subsets']) && ($group['subsets']>0)) for ($i = 0; $i < $group['subsets']; $i++) {
if (isset($this->_result['devices'][$gid."-".$i]['items'][0]['parentid'])) {
foreach ($this->_result['devices'][$gid."-".$i]['items'] as $fid=>$from) {
if ($fid===0) {
$this->_result['devices'][$gid]['items'][$gid."-".$i]['parentid'] = 1;
Avoid deeply nested control flow statements. Open
Open
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ('dir' !== filetype($dir . '/' . $file) && 'index.html' !== $file && 'adminmenu.php' !== $file) {
@unlink($dir . '/' . $file);
Avoid deeply nested control flow statements. Open
Open
if (strlen($buffer) > 0) {
$this->_filecontent['idrac'][$device] = $buffer;
}
Avoid deeply nested control flow statements. Open
Open
if (!defined('PSI_MODE_POPEN')) { //if not overloaded in phpsysinfo.ini
if (!function_exists("proc_open")) { //proc_open function test by executing 'pwd' command
define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
} else {
$out = '';
Avoid deeply nested control flow statements. Open
Open
switch ($details[2]) {
case 'BAD':
case 'ready':
$itemn = $group .'-'.'unconfigured';
break;
Avoid deeply nested control flow statements. Open
Open
if ($battery !== '') $this->_result['devices'][$prefix.$itemn]['battery'] = $battery;
Avoid deeply nested control flow statements. Open
Open
if (($itemn !== '') && isset($this->_result['devices'][$prefix.$itemn])) {
$this->_result['devices'][$prefix.$itemn]['items'][$details[0]]['parentid'] = 1;
$this->_result['devices'][$prefix.$itemn]['items'][$details[0]]['type'] = 'disk';
$this->_result['devices'][$prefix.$itemn]['items'][$details[0]]['name'] = $details[0];
$this->_result['devices'][$prefix.$itemn]['items'][$details[0]]['info'] = $details[2];
Avoid deeply nested control flow statements. Open
Open
switch ($details[5]) {
case 'optimal':
$this->_result['devices'][$prefix.$details[0]]['items'][$details[0]]['status'] = "ok";
break;
case 'OFFLINE':
Avoid deeply nested control flow statements. Open
Open
if ($indent > $lastindent) {
$lastparentids[$indent] = $lastid;
}
Avoid deeply nested control flow statements. Open
Open
if (!defined('PSI_SYSTEM_LANG') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
foreach ($lines2 as $line) {
if (preg_match('/^LC_MESSAGES="?([^\."@]*)/', $line, $matches2)) {
$lang = "";
if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
Avoid deeply nested control flow statements. Open
Open
switch ($unit) {
case 'B':
$this->_result['devices'][$prefix.$details[0]]['size'] = $value;
break;
case 'KiB':
Consider simplifying this complex logical expression. Open
Open
if (p111 || p112 || p113 || p114 || p115 || p116) {
processes += " (";
for (var proc_type in {111:0,112:1,113:2,114:3,115:4,116:5}) {
if (eval("p" + proc_type)) {
if (not_first) {
Consider simplifying this complex logical expression. Open
Open
if (prunning || psleeping || pstopped || pzombie || pwaiting || pother) {
$("#s_processes_1").append(" (");
$("#s_processes_2").append(" (");
var typelist = {running:111,sleeping:112,stopped:113,zombie:114,waiting:115,other:116};
for (var proc_type in typelist) {