XoopsModules25x/about

View on GitHub
include/oninstall.php

Summary

Maintainability
A
1 hr
Test Coverage

xoops_module_pre_install_about accesses the super-global variable $GLOBALS.
Open

function xoops_module_pre_install_about(\XoopsModule $module)
{
    require_once dirname(__DIR__) . '/preloads/autoloader.php';
    $utility      = new Utility();
    $xoopsSuccess = $utility::checkVerXoops($module);
Severity: Minor
Found in include/oninstall.php by phpmd

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_install_about accesses the super-global variable $GLOBALS.
Open

function xoops_module_install_about(\XoopsModule $module)
{
    require_once dirname(__DIR__, 3) . '/mainfile.php';

    $moduleDirName = basename(dirname(__DIR__));
Severity: Minor
Found in include/oninstall.php by phpmd

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_install_about accesses the super-global variable $GLOBALS.
Open

function xoops_module_install_about(\XoopsModule $module)
{
    require_once dirname(__DIR__, 3) . '/mainfile.php';

    $moduleDirName = basename(dirname(__DIR__));
Severity: Minor
Found in include/oninstall.php by phpmd

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_about accesses the super-global variable $GLOBALS.
Open

function xoops_module_pre_install_about(\XoopsModule $module)
{
    require_once dirname(__DIR__) . '/preloads/autoloader.php';
    $utility      = new Utility();
    $xoopsSuccess = $utility::checkVerXoops($module);
Severity: Minor
Found in include/oninstall.php by phpmd

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_about has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function xoops_module_install_about(\XoopsModule $module)
{
    require_once dirname(__DIR__, 3) . '/mainfile.php';

    $moduleDirName = basename(dirname(__DIR__));
Severity: Minor
Found in include/oninstall.php - About 1 hr to fix

    Function xoops_module_install_about has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function xoops_module_install_about(\XoopsModule $module)
    {
        require_once dirname(__DIR__, 3) . '/mainfile.php';
    
        $moduleDirName = basename(dirname(__DIR__));
    Severity: Minor
    Found in include/oninstall.php - About 25 mins to fix

    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 unused parameters such as '$module'.
    Open

    function xoops_module_install_about(\XoopsModule $module)
    Severity: Minor
    Found in include/oninstall.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid using static access to class '\XoopsModules\About\Helper' in method 'xoops_module_install_about'.
    Open

        $helper       = Helper::getInstance();
    Severity: Minor
    Found in include/oninstall.php by phpmd

    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

    There must be one USE keyword per declaration
    Open

    use XoopsModules\About\{
    Severity: Minor
    Found in include/oninstall.php by phpcodesniffer

    Line exceeds 120 characters; contains 170 characters
    Open

        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
    Severity: Minor
    Found in include/oninstall.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status