Showing 1,065 of 16,781 total issues
Avoid deeply nested control flow statements. Open
Open
switch ($bufferWB[$bi]['BatteryStatus']) {
case 1: $batstat = 'Discharging'; break;
case 2: $batstat = 'AC connected'; break;
case 3: $batstat = 'Fully Charged'; break;
case 4: $batstat = 'Low'; break;
Avoid deeply nested control flow statements. Open
Open
switch ($bufferWPB[$bi]['Chemistry']) {
case 1: $techn = 'Other'; break;
case 2: $techn = 'Unknown'; break;
case 3: $techn = 'PbAc'; break;
case 4: $techn = 'NiCd'; break;
Avoid deeply nested control flow statements. Open
Open
if (($rfts_bi && ($infoitem!=='')) || ($rfts_bs && ($stateitem!==''))) {
if (preg_match('/^\/proc\/acpi\/battery\/(.+)\/info$/', $batdevices[$i], $batname)) {
if ($infoitem!=='') {
$infoitem .= 'POWER_SUPPLY_NAME='.$batname[1]."\n";
} else {
Avoid deeply nested control flow statements. Open
Open
if (isset($bufferBS[$bi]['RemainingCapacity']) &&
(($bufferBS[$bi]['RemainingCapacity']>0) || ($hasvolt && ($bufferBS[$bi]['RemainingCapacity']==0)))) {
$buffer[$bi]['state'] .= 'POWER_SUPPLY_ENERGY_NOW='.($bufferBS[$bi]['RemainingCapacity']*1000)."\n";
$capacity = '';
}
Avoid deeply nested control flow statements. Open
Open
if (isset($this->_result['devices'][$prefix.$details[2]])) {
$this->_result['devices'][$prefix.$details[2]]['items'][$details[0]]['parentid'] = 1;
$this->_result['devices'][$prefix.$details[2]]['items'][$details[0]]['type'] = 'disk';
$this->_result['devices'][$prefix.$details[2]]['items'][$details[0]]['name'] = $details[0];
if ($details[3] !== 'online') {
Avoid deeply nested control flow statements. Open
Open
if ($rootoffset === false) { // first line means root
$rootoffset = $offset;
$this->_result['devices'][$group]['items'][$id]['name'] = "";//$fullbuff[0];
if (count($fullbuff) > 1) {
$this->_result['devices'][$group]['items'][$id]['status'] = $fullbuff[1];
Avoid deeply nested control flow statements. Open
Open
if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
if (!defined('PSI_SYSTEM_CODEPAGE') && isset($matches2[2]) && !is_null($matches2[2]) && (trim($matches2[2]) != "")) { //also if not overloaded in phpsysinfo.ini
define('PSI_SYSTEM_CODEPAGE', $matches2[2]);
}
Avoid deeply nested control flow statements. Open
Open
while (false !== ($sentry = readdir($shandle))) {
if (($sentry!=".")&&($sentry!="..")) {
$log_file=PSI_APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry;
echo "<tr>";
echo "<td>".$entry.'/'.$sentry."</td>";
Function filemtime_override
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function filemtime_override($dirname, $template, $theme = '', $block = false)
{
global $xoopsConfig;
$themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
- 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 ($details[5] !== 'optimal') {
$this->_result['devices'][$prefix.$details[0]]['items'][$details[0]]['info'] = $details[5];
}
Avoid deeply nested control flow statements. Open
Open
if ($lastparentids[$indent] >= 0) {
if (isset($this->_result['devices'][$group]['items'][$lastparentids[$indent]]['childs'])) {
$this->_result['devices'][$group]['items'][$lastparentids[$indent]]['childs']++;
} else {
$this->_result['devices'][$group]['items'][$lastparentids[$indent]]['childs'] = 1;
Avoid deeply nested control flow statements. Open
Open
if ($offset < $rootoffset) { // some errors
continue;
}
Avoid deeply nested control flow statements. Open
Open
if (!defined('PSI_SYSTEM_CODEPAGE')) {
if (file_exists($vtfname = '/sys/module/vt/parameters/default_utf8')
&& (trim(@file_get_contents($vtfname)) === "1")) {
define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
} elseif (@exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
Avoid deeply nested control flow statements. Open
Open
if ($controller !== '') $this->_result['devices'][$prefix.$itemn]['controller'] = $controller;
Avoid deeply nested control flow statements. Open
Open
if (count($fullbuff) > 1) {
$this->_result['devices'][$group]['items'][$id]['status'] = $fullbuff[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) {
@unlink($dir . '/' . $file);
Avoid deeply nested control flow statements. Open
Open
if (($id != 0) && ($id != 255)) {
switch ($id) {
case 3:
//raw16(avg16)
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6])."\n";
Avoid deeply nested control flow statements. Open
Open
if (count($fullbuff) > 5) {
$this->_result['devices'][$group]['items'][$id]['info'] = $fullbuff[5];
}
Avoid deeply nested control flow statements. Open
Open
if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
if (isset($langdata['Linux']['_'.$lines[0]])) {
$lang = $langdata['Linux']['_'.$lines[0]];
}
}
Avoid deeply nested control flow statements. Open
Open
if ($controller !== '') $this->_result['devices'][$prefix.$details[0]]['controller'] = $controller;