xoops_module_pre_install_xfguestbook accesses the super-global variable $GLOBALS. Open
function xoops_module_pre_install_xfguestbook(\XoopsModule $module)
{
require __DIR__ . '/common.php';
$utility = new Utility();
//check for minimum XOOPS version
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
xoops_module_pre_install_xfguestbook accesses the super-global variable $GLOBALS. Open
function xoops_module_pre_install_xfguestbook(\XoopsModule $module)
{
require __DIR__ . '/common.php';
$utility = new Utility();
//check for minimum XOOPS version
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method xoops_module_install_xfguestbook
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function xoops_module_install_xfguestbook(\XoopsModule $module)
{
require_once dirname(__DIR__) . '/preloads/autoloader.php';
$moduleDirName = basename(dirname(__DIR__));
Function xoops_module_install_xfguestbook
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function xoops_module_install_xfguestbook(\XoopsModule $module)
{
require_once dirname(__DIR__) . '/preloads/autoloader.php';
$moduleDirName = basename(dirname(__DIR__));
- 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
Avoid using static access to class '\XoopsModules\Xfguestbook\Helper' in method 'xoops_module_install_xfguestbook'. Open
$helper = Helper::getInstance();
- 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 unused local variables such as '$xoopsModule'. Open
global $xoopsModule;
- 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
}
}