XoopsModules25x/xoopsinfo

View on GitHub

Showing 1,065 of 16,781 total issues

Avoid deeply nested control flow statements.
Open

                            if ($battery !== '') $this->_result['devices'][$prefix.$details[0]]['battery'] = $battery;
Severity: Major
Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if ($lang == "") {
                        $lang = 'Unknown';
                    }
    Severity: Major
    Found in phpsysinfo/read_config.php - About 45 mins to fix

      Function execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute()
          {
              $this->_lines = array();
              switch (strtolower(PSI_PLUGIN_DOCKER_ACCESS)) {
                  case 'command':
      Severity: Minor
      Found in phpsysinfo/plugins/docker/class.docker.inc.php - About 45 mins to fix

      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

                                      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") {
      Severity: Major
      Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        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";
                                    }
        Severity: Major
        Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (@exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
                                  define('PSI_UNAMEO', $unameo0);
                              }
          Severity: Major
          Found in phpsysinfo/read_config.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            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'];
            Severity: Major
            Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              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;
              Severity: Major
              Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                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);
                Severity: Major
                Found in modules/xoopsinfo/admin/rescue.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                  if (strlen($buffer) > 0) {
                                                      $this->_filecontent['idrac'][$device] = $buffer;
                                                  }
                  Severity: Major
                  Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    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 = '';
                    Severity: Major
                    Found in phpsysinfo/read_config.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  switch ($details[2]) {
                                                      case 'BAD':
                                                      case 'ready':
                                                          $itemn = $group .'-'.'unconfigured';
                                                          break;
                      Severity: Major
                      Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if ($battery !== '') $this->_result['devices'][$prefix.$itemn]['battery'] = $battery;
                        Severity: Major
                        Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          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];
                          Severity: Major
                          Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        switch ($details[5]) {
                                                            case 'optimal':
                                                                $this->_result['devices'][$prefix.$details[0]]['items'][$details[0]]['status'] = "ok";
                                                                break;
                                                            case 'OFFLINE':
                            Severity: Major
                            Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if ($indent > $lastindent) {
                                                              $lastparentids[$indent] = $lastid;
                                                          }
                              Severity: Major
                              Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                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))) {
                                Severity: Major
                                Found in phpsysinfo/read_config.php - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              switch ($unit) {
                                                                  case 'B':
                                                                      $this->_result['devices'][$prefix.$details[0]]['size'] = $value;
                                                                      break;
                                                                  case 'KiB':
                                  Severity: Major
                                  Found in phpsysinfo/plugins/raid/class.raid.inc.php - About 45 mins to fix

                                    Consider simplifying this complex logical expression.
                                    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) {
                                    Severity: Major
                                    Found in phpsysinfo/js/phpSysInfo/phpsysinfo_bootstrap.js - About 40 mins to fix

                                      Consider simplifying this complex logical expression.
                                      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) {
                                      Severity: Major
                                      Found in phpsysinfo/js/phpSysInfo/phpsysinfo.js - About 40 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language