detain/myadmin-plugin-installer

View on GitHub
src/modules.php

Summary

Maintainability
B
4 hrs
Test Coverage

Function get_module_db has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function get_module_db($module)
{
    if ($module == 'powerdns') {
        if (!isset($GLOBALS['powerdns_dbh'])) {
            $GLOBALS['powerdns_dbh'] = new \MyDb\Mdb2\Db(POWERDNS_DB, POWERDNS_USER, POWERDNS_PASSWORD, POWERDNS_HOST);
Severity: Minor
Found in src/modules.php - About 1 hr 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

Function get_module_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function get_module_name($module = 'default')
{
    if ($module != 'default') {
        if (isset($GLOBALS[$module.'_dbh'])) {
            return $module;
Severity: Minor
Found in src/modules.php - About 1 hr 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 too many return statements within this method.
Open

    return 'default';
Severity: Major
Found in src/modules.php - About 30 mins to fix

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

    function get_module_settings($module = 'default', $setting = false)
    {
        if (!isset($GLOBALS['modules'][$module])) {
            $keys = array_keys($GLOBALS['modules']);
            $module = $keys[0];
    Severity: Minor
    Found in src/modules.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

    Missing class import via use statement (line '134', column '43').
    Open

                $GLOBALS['zonemta_dbh'] = new \MyDb\Mysqli\Db(ZONEMTA_MYSQL_DB, ZONEMTA_MYSQL_USERNAME, ZONEMTA_MYSQL_PASSWORD, ZONEMTA_MYSQL_HOST);
    Severity: Minor
    Found in src/modules.php by phpmd

    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

    Missing class import via use statement (line '128', column '44').
    Open

                $GLOBALS['powerdns_dbh'] = new \MyDb\Mdb2\Db(POWERDNS_DB, POWERDNS_USER, POWERDNS_PASSWORD, POWERDNS_HOST);
    Severity: Minor
    Found in src/modules.php by phpmd

    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 '$idx'.
    Open

            foreach ($tkeys as $idx => $key) {
    Severity: Minor
    Found in src/modules.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

    There are no issues that match your filters.

    Category
    Status