Function __construct
has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_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
Method __construct
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
The class PS has an overall complexity of 61 which is very high. The configured complexity threshold is 50. Open
class PS extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
- Exclude checks
Function execute
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function execute()
{
if (empty($this->_filecontent)) {
return;
}
- 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
Function _addchild
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
{
foreach ($child as $key=>$value) {
$xmlnode = $xml->addChild("Process");
if (isset($value[0])) {
- 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
Method execute
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute()
{
if (empty($this->_filecontent)) {
return;
}
Method _addchild
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
{
foreach ($child as $key=>$value) {
$xmlnode = $xml->addChild("Process");
if (isset($value[0])) {
Consider simplifying this complex logical expression. Open
if ((PSI_OS !== 'WINNT') &&
((($parentid === 1) && (!defined('PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED === false)))
|| ((!defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false)) && ($value[4] === "[kthreadd]")))) {
$xmlnode->addAttribute('Expanded', 0);
}
Avoid deeply nested control flow statements. Open
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
if (($totalmem != 0) && (preg_match('/^VmRSS:\s+(\d+)\s+kB/m', $buf, $tmppmem))) {
$pmem = round(100 * $tmppmem[1] / $totalmem, 1);
The method __construct() has 124 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Exclude checks
The method __construct() has an NPath complexity of 831. The configured NPath complexity threshold is 200. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method _addchild() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
{
foreach ($child as $key=>$value) {
$xmlnode = $xml->addChild("Process");
if (isset($value[0])) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method execute() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function execute()
{
if (empty($this->_filecontent)) {
return;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method __construct() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Avoid using undefined variables such as '$mbuf' which will lead to PHP notices. Open
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$namebuf' which will lead to PHP notices. Open
if (CommonFunctions::rfts(substr($process[$i], 0, strlen($process[$i])-6)."cmdline", $namebuf, 0, 4096, false)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$mbuf' which will lead to PHP notices. Open
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$namebuf' which will lead to PHP notices. Open
$name = str_replace(chr(0), ' ', trim($namebuf));
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '42', column '39'). Open
$objLocator = new COM('WbemScripting.SWbemLocator');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
CommonFunctions::executeProgram("ps", "axo pid,ppid,pmem,pcpu,args", $buffer, PSI_DEBUG);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
$process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'CommandLine', 'ProcessId', 'ParentProcessId', 'WorkingSetSize'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$ps = trim($process['Caption']);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
if (CommonFunctions::rfts(substr($process[$i], 0, strlen($process[$i])-6)."cmdline", $namebuf, 0, 4096, false)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '64', column '30'). Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$args = "[".$args."]";
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
$perf_wmi = CommonFunctions::getWMI($wmi, 'Win32_PerfFormattedData_PerfProc_Process', array('IDProcess', 'CreatingProcessID', 'PercentProcessorTime'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
CommonFunctions::executeProgram("ps", "axo pid,ppid,pmem,pcpu,args", $buffer, PSI_DEBUG);
if (((PSI_OS == 'Linux') || (PSI_OS == 'Android')) && (!preg_match("/^[^\n]+\n\s*\d+\s+\d+\s+[\d\.]+\s+[\d\.]+\s+.+/", $buffer))) { //alternative method if no data
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method execute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_result = array();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$pmem = 0;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
$os_wmi = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('TotalVisibleMemorySize'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '99', column '57'). Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'CommonFunctions' in method '__construct'. Open
CommonFunctions::rfts(PSI_APP_ROOT."/data/ps.txt", $buffer);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_filecontent = array();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using empty try-catch blocks in __construct. Open
} catch (Exception $e) {
}
- Read upRead up
- Exclude checks
EmptyCatchBlock
Since: 2.7.0
Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.
Example
class Foo {
public function bar()
{
try {
// ...
} catch (Exception $e) {} // empty catch block
}
}
Source https://phpmd.org/rules/design.html#emptycatchblock
Avoid unused local variables such as '$key'. Open
foreach ($child as $key=>$value) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
TODO found Open
//=> subtrees of processes may be missing (WHAT TODO?!?)
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class PS extends PSI_Plugin
- Exclude checks
Avoid classes with short names like PS. Configured minimum length is 3. Open
class PS extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid variables with short names like $ps. Configured minimum length is 3. Open
$ps = trim($process['CommandLine']);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $_filecontent is not named in camelCase. Open
class PS extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_result is not named in camelCase. Open
class PS extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Property name "$_result" should not be prefixed with an underscore to indicate visibility Open
private $_result = array();
- Exclude checks
Property name "$_filecontent" should not be prefixed with an underscore to indicate visibility Open
private $_filecontent = array();
- Exclude checks
Blank line found at start of control structure Open
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
- Exclude checks
Blank line found at end of control structure Open
- Exclude checks
Expected 1 space after "=>"; 0 found Open
foreach ($child as $key=>$value) {
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Expected 1 space before "=>"; 0 found Open
foreach ($child as $key=>$value) {
- Exclude checks
Expected 1 space before "=>"; 0 found Open
foreach ($row as $key=>$val) {
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Expected 1 space after "=>"; 0 found Open
foreach ($row as $key=>$val) {
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Method name "_addchild" should not be prefixed with an underscore to indicate visibility Open
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
//possible that ParentProcessId incorrectly refers to a process that reuses a process identifier. You can
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
//use the CreationDate property to determine whether the specified parent was created after the process
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
$process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'CommandLine', 'ProcessId', 'ParentProcessId', 'WorkingSetSize'));
- Exclude checks
Line exceeds 120 characters; contains 181 characters Open
$proccpu[trim($perf['IDProcess'])] = array('ParentProcessId'=>trim($perf['CreatingProcessID']), 'PercentProcessorTime'=>trim($perf['PercentProcessorTime']));
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
|| ((!defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false)) && ($value[4] === "[kthreadd]")))) {
- Exclude checks
Line exceeds 120 characters; contains 171 characters Open
$perf_wmi = CommonFunctions::getWMI($wmi, 'Win32_PerfFormattedData_PerfProc_Process', array('IDProcess', 'CreatingProcessID', 'PercentProcessorTime'));
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
if (CommonFunctions::rfts(substr($process[$i], 0, strlen($process[$i])-6)."cmdline", $namebuf, 0, 4096, false)) {
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
//only identify a process for the lifetime of that process. It is possible that the process identified by
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
//ParentProcessId is terminated, so ParentProcessId may not refer to a running process. It is also
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
//Unique identifier of the process that creates a process. Process identifier numbers are reused, so they
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
((($parentid === 1) && (!defined('PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED === false)))
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$perf_wmi = CommonFunctions::getWMI($wmi, 'Win32_PerfFormattedData_PerfProc_Process', array('IDProcess', 'CreatingProcessID', 'PercentProcessorTime'));
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
foreach ($process_wmi as $process) {
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$this->_filecontent[] = $procid." ".$parentid." ".$memusage." ".$cpu." ".$ps;
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
if (((PSI_OS == 'Linux') || (PSI_OS == 'Android')) && (!preg_match("/^[^\n]+\n\s*\d+\s+\d+\s+[\d\.]+\s+[\d\.]+\s+.+/", $buffer))) { //alternative method if no data
- Exclude checks
Line indented incorrectly; expected at least 36 spaces, found 32 Open
$totalmem = $ar_buf[1];
- Exclude checks
Line indented incorrectly; expected at least 44 spaces, found 40 Open
$pmem = round(100 * $tmppmem[1] / $totalmem, 1);
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$memtotal = 0;
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'CommandLine', 'ProcessId', 'ParentProcessId', 'WorkingSetSize'));
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$ps = trim($process['Caption']);
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
try {
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$os_wmi = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('TotalVisibleMemorySize'));
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
foreach ($perf_wmi as $perf) {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
}
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 16 Open
CommonFunctions::executeProgram("ps", "axo pid,ppid,pmem,pcpu,args", $buffer, PSI_DEBUG);
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$memtotal = $os['TotalVisibleMemorySize'] * 1024;
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$parentid = trim($process['ParentProcessId']);
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$totalmem = 0;
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
for ($i = 0; $i < $total; $i++) {
- Exclude checks
Line indented incorrectly; expected at least 36 spaces, found 32 Open
$cpu = $proccpu[$procid]['PercentProcessorTime'];
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$process = array();
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
if (($totalmem != 0) && (preg_match('/^VmRSS:\s+(\d+)\s+kB/m', $buf, $tmppmem))) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
if (PSI_OS == 'WINNT') {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
foreach ($os_wmi as $os) {
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$proccpu = array();
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
}
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$processlist = glob('/proc/*/status', GLOB_NOSORT);
- Exclude checks
Line indented incorrectly; expected 48 spaces, found 40 Open
}
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$buffer = " PID PPID %MEM %CPU COMMAND\n";
- Exclude checks
Line indented incorrectly; expected 36 spaces, found 32 Open
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
foreach ($bufe as $buf) {
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
foreach ($processlist as $processitem) { //second sort
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
} else {
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
if (CommonFunctions::rfts(substr($process[$i], 0, strlen($process[$i])-6)."cmdline", $namebuf, 0, 4096, false)) {
- Exclude checks
Line indented incorrectly; expected at least 48 spaces, found 40 Open
$buffer .= $pid." ".$ppid." ".$pmem." 0.0 ".$args."\n";
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
if (isset($proccpu[$procid]) && ($proccpu[$procid]['ParentProcessId'] == $parentid)) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
} else {
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
} else {
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$memusage = round(trim($process['WorkingSetSize']) * 100 / $memtotal, 1);
- Exclude checks
Line indented incorrectly; expected 52 spaces, found 44 Open
} else {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
case 'command':
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$objLocator = new COM('WbemScripting.SWbemLocator');
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$ps = trim($process['CommandLine']);
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
if (($procid = trim($process['ProcessId'])) != 0) {
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
} catch (Exception $e) {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 20 Open
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
- Exclude checks
Line indented incorrectly; expected at least 36 spaces, found 32 Open
break;
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$buf = "";
- Exclude checks
Line indented incorrectly; expected at least 48 spaces, found 40 Open
$pid = $tmppid[1];
- Exclude checks
Line indented incorrectly; expected 52 spaces, found 44 Open
if ($name !== "") {
- Exclude checks
Line indented incorrectly; expected 52 spaces, found 44 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
}
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 28 Open
}
- Exclude checks
Line indented incorrectly; expected at least 44 spaces, found 40 Open
$pmem = 0;
- Exclude checks
Line indented incorrectly; expected at least 40 spaces, found 36 Open
$name = null;
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 12 Open
CommonFunctions::rfts(PSI_APP_ROOT."/data/ps.txt", $buffer);
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
}
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 12 Open
$this->global_error->addConfigError("__construct()", "[ps] ACCESS");
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
$proccpu[trim($perf['IDProcess'])] = array('ParentProcessId'=>trim($perf['CreatingProcessID']), 'PercentProcessorTime'=>trim($perf['PercentProcessorTime']));
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected at least 36 spaces, found 32 Open
$process[] = $processitem;
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
if (preg_match('/^Pid:\s+(\d+)/m', $buf, $tmppid) &&
- Exclude checks
Line indented incorrectly; expected at least 44 spaces, found 40 Open
$name = str_replace(chr(0), ' ', trim($namebuf));
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
default:
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
natsort($processlist); //first sort
- Exclude checks
Line indented incorrectly; expected at least 48 spaces, found 40 Open
$args = $tmpargs[1];
- Exclude checks
Line indented incorrectly; expected 36 spaces, found 32 Open
}
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
$wmi = $objLocator->ConnectServer('', 'root\CIMv2');
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 24 Open
break;
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
if (strlen(trim($process['CommandLine'])) > 0) {
- Exclude checks
Line indented incorrectly; expected at least 32 spaces, found 28 Open
$cpu = 0;
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
if (is_array($processlist) && (($total = count($processlist)) > 0)) {
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
}
- Exclude checks
Line indented incorrectly; expected 48 spaces, found 40 Open
if ($name !== null) {
- Exclude checks
Line indented incorrectly; expected at least 48 spaces, found 40 Open
$ppid = $tmpppid[1];
- Exclude checks
Line indented incorrectly; expected at least 56 spaces, found 48 Open
$args = "[".$args."]";
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected 40 spaces, found 36 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
case 'data':
- Exclude checks
Line indented incorrectly; expected at least 56 spaces, found 48 Open
$args = $name;
- Exclude checks
The variable $process_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $perf_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ar_buf is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $os_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $perf_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $process_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ar_buf is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $os_wmi is not named in camelCase. Open
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
case 'command':
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _addchild is not named in camelCase. Open
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
{
foreach ($child as $key=>$value) {
$xmlnode = $xml->addChild("Process");
if (isset($value[0])) {
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}