detain/myadmin-servers-module

View on GitHub
bin/update_ipmi.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function update_ipmi_ip has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

function update_ipmi_ip()
{
    require_once __DIR__.'/../../../../include/functions.inc.php';
    if (isset($_SERVER['argv'])) {
        $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
Severity: Minor
Found in bin/update_ipmi.php - About 3 hrs 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

Method update_ipmi_ip has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function update_ipmi_ip()
{
    require_once __DIR__.'/../../../../include/functions.inc.php';
    if (isset($_SERVER['argv'])) {
        $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
Severity: Minor
Found in bin/update_ipmi.php - About 1 hr to fix

    The function update_ipmi_ip() contains an exit expression.
    Open

                exit;
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

    Source https://phpmd.org/rules/design.html#exitexpression

    The function update_ipmi_ip() contains an exit expression.
    Open

            die('You\'re not authorized');
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

    Source https://phpmd.org/rules/design.html#exitexpression

    Avoid unused local variables such as '$server_id'.
    Open

                        $server_id = $db->Record['id'];
    Severity: Minor
    Found in bin/update_ipmi.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

    The variable $ip_val is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $server_id is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_val is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_val is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_val is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_val is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mac_key is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $server_id is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mac_key is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mac_key is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mac_key is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mac_key is not named in camelCase.
    Open

    function update_ipmi_ip()
    {
        require_once __DIR__.'/../../../../include/functions.inc.php';
        if (isset($_SERVER['argv'])) {
            $GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
    Severity: Minor
    Found in bin/update_ipmi.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status