mambax7/adslight

View on GitHub
include/oninstall.php

Summary

Maintainability
A
2 hrs
Test Coverage

xoops_module_pre_install_adslight accesses the super-global variable $GLOBALS.
Open

function xoops_module_pre_install_adslight(\XoopsModule $module): bool
{
    require_once __DIR__ . '/common.php';
    $utility = new Utility();
    //check for minimum XOOPS version
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_adslight accesses the super-global variable $GLOBALS.
Open

function xoops_module_pre_install_adslight(\XoopsModule $module): bool
{
    require_once __DIR__ . '/common.php';
    $utility = new Utility();
    //check for minimum XOOPS version
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_adslight has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    global $xoopsDB;
Severity: Minor
Found in include/oninstall.php - About 1 hr to fix

    Function xoops_module_install_adslight has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function xoops_module_install_adslight(\XoopsModule $module): bool
    {
        require_once \dirname(__DIR__, 3) . '/mainfile.php';
    
        global $xoopsDB;
    Severity: Minor
    Found in include/oninstall.php - About 45 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 local variables such as '$rowsCount'.
    Open

        $rowsCount = $xoopsDB->getRowsNum($xoopsDB->query($sql));
    Severity: Minor
    Found in include/oninstall.php by phpmd

    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

    Avoid unused parameters such as '$module'.
    Open

    function xoops_module_install_adslight(\XoopsModule $module): bool
    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

    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 31 and the first side effect is on line 23.
    Open

    <?php declare(strict_types=1);
    Severity: Minor
    Found in include/oninstall.php by phpcodesniffer

    There must be one USE keyword per declaration
    Open

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

    There are no issues that match your filters.

    Category
    Status