File read_config.php
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
if (!defined('PSI_CONFIG_FILE')) {
/**
* phpSysInfo version
*/
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]);
}
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
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]];
}
}
Avoid deeply nested control flow statements. Open
if ($lang == "") {
$lang = 'Unknown';
}
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);
}
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 = '';
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))) {
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')) {
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')
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]];
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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]])) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Exclude checks
Expected 1 space after "=>"; 0 found Open
foreach ($group as $param=>$value) {
- Exclude checks
Expected 1 space before "=>"; 0 found Open
foreach ($group as $param=>$value) {
- Exclude checks
Expected 1 space after "=>"; 0 found Open
foreach ($config as $name=>$group) {
- Exclude checks
Expected 1 space before "=>"; 0 found Open
foreach ($config as $name=>$group) {
- Exclude checks
Blank line found at start of control structure Open
if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
- Exclude checks
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))) {
- Exclude checks
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))) {
- Exclude checks
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))) {
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
- Exclude checks
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
- Exclude checks
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).';');
- Exclude checks
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
- Exclude checks
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
- Exclude checks
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
- Exclude checks
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)
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
if (@exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
- Exclude checks
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
- Exclude checks