XoopsModules25x/xoopsinfo

View on GitHub
phpsysinfo/read_config.php

Summary

Maintainability
D
1 day
Test Coverage

File read_config.php has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
if (!defined('PSI_CONFIG_FILE')) {
    /**
     * phpSysInfo version
     */
Severity: Minor
Found in phpsysinfo/read_config.php - About 2 hrs 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 ($lang == "") {
                          $lang = 'Unknown';
                      }
      Severity: Major
      Found in phpsysinfo/read_config.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        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
        Severity: Major
        Found in phpsysinfo/read_config.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

                            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

                                  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]);
                                      }
              Severity: Major
              Found in phpsysinfo/read_config.php - About 45 mins to fix

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

                  Consider simplifying this complex logical expression.
                  Open

                              if (file_exists($fname = '/etc/sysconfig/i18n')
                                 || file_exists($fname = '/etc/default/locale')
                                 || file_exists($fname = '/etc/locale.conf')
                                 || file_exists($fname = '/etc/sysconfig/language')
                                 || file_exists($fname = '/etc/profile.d/lang.sh')
                  Severity: Major
                  Found in phpsysinfo/read_config.php - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
                                   && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
                                   || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
                                   || preg_match('/^\s*export (LANG="?[^"\n]*"?)/m', $contents, $matches))) {
                                    if (!defined('PSI_SYSTEM_CODEPAGE')) {
                    Severity: Major
                    Found in phpsysinfo/read_config.php - About 40 mins to fix

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

                                              if (!defined('PSI_SYSTEM_LANG')) { //if not overloaded in phpsysinfo.ini
                                                  $lang = "";
                                                  if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
                                                      if (isset($langdata['Linux']['_'.$matches2[1]])) {
                                                          $lang = $langdata['Linux']['_'.$matches2[1]];
                      Severity: Major
                      Found in phpsysinfo/read_config.php and 1 other location - About 3 hrs to fix
                      phpsysinfo/read_config.php on lines 229..241

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 148.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

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

                                  if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
                                      && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
                                      $lang = "";
                                      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]])) {
                      Severity: Major
                      Found in phpsysinfo/read_config.php and 1 other location - About 3 hrs to fix
                      phpsysinfo/read_config.php on lines 212..223

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 148.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 6 and the first side effect is on line 21.
                      Open

                      <?php
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Expected 1 space before "=>"; 0 found
                      Open

                              foreach ($config as $name=>$group) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Expected 1 space after "=>"; 0 found
                      Open

                              foreach ($config as $name=>$group) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Expected 1 space before "=>"; 0 found
                      Open

                                  foreach ($group as $param=>$value) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Expected 1 space after "=>"; 0 found
                      Open

                                  foreach ($group as $param=>$value) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Blank line found at start of control structure
                      Open

                                          if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 142 characters
                      Open

                                                  define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 157 characters
                      Open

                                              define($name_prefix.strtoupper($param), 'return '.var_export(preg_split('/\s*,\s*/', trim($value), -1, PREG_SPLIT_NO_EMPTY), 1).';');
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 131 characters
                      Open

                                          } elseif (@exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 145 characters
                      Open

                                      if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 127 characters
                      Open

                                  if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 134 characters
                      Open

                              if (simplexml_load_string("<A><B><C/></B>\n</A>") !== simplexml_load_string("<A><B><C/></B></A>")) { // json_encode issue test
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 157 characters
                      Open

                                                  if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 127 characters
                      Open

                                  if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 146 characters
                      Open

                                      if (!defined('PSI_SYSTEM_LANG') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 157 characters
                      Open

                                                  if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 129 characters
                      Open

                                          if (@exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      Line exceeds 120 characters; contains 121 characters
                      Open

                                                  $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
                      Severity: Minor
                      Found in phpsysinfo/read_config.php by phpcodesniffer

                      There are no issues that match your filters.

                      Category
                      Status