src/activate_webuzo.php
The function activate_webuzo() calls the typical debug function print_r() which is mostly only used during development. Open
Open
myadmin_log('myadmin', 'debug', 'webuzoBuy error:'.print_r($noc->error, true), __LINE__, __FILE__);
- Read upRead up
- Exclude checks
DevelopmentCodeFragment
Since: 2.3.0
Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.
Example
class SuspectCode {
public function doSomething(array $items)
{
foreach ($items as $i => $item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
Source https://phpmd.org/rules/design.html#developmentcodefragment
Function activate_webuzo
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
function activate_webuzo($ipAddress, $field = '', $email = '')
{
myadmin_log('softaculous', 'info', "activating webuzo({$ipAddress}, {$field}, {$email})", __LINE__, __FILE__);
try {
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(WEBUZO_USERNAME, WEBUZO_PASSWORD);
- 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 activate_webuzo
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function activate_webuzo($ipAddress, $field = '', $email = '')
{
myadmin_log('softaculous', 'info', "activating webuzo({$ipAddress}, {$field}, {$email})", __LINE__, __FILE__);
try {
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(WEBUZO_USERNAME, WEBUZO_PASSWORD);
Missing class import via use statement (line '22', column '20'). Open
Open
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(WEBUZO_USERNAME, WEBUZO_PASSWORD);
- 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 unused local variables such as '$need'. Open
Open
$need = false;
- 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
}
}