detain/myadmin-cpanel-webhosting

View on GitHub
src/api.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method api_auto_cpanel_login has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function api_auto_cpanel_login($id)
{
    $return = ['status' => 'error', 'status_text' => ''];
    $module = 'webhosting';
    $custid = get_custid($GLOBALS['tf']->session->account_id, 'vps');
Severity: Minor
Found in src/api.php - About 1 hr to fix

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

    function api_auto_cpanel_login($id)
    {
        $return = ['status' => 'error', 'status_text' => ''];
        $module = 'webhosting';
        $custid = get_custid($GLOBALS['tf']->session->account_id, 'vps');
    Severity: Minor
    Found in src/api.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 using undefined variables such as '$header' which will lead to PHP notices.
    Open

            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);         // Set the username and password.
    Severity: Minor
    Found in src/api.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$header' which will lead to PHP notices.
    Open

            $header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'", '', $hash);
    Severity: Minor
    Found in src/api.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

        $custid = get_custid($GLOBALS['tf']->session->account_id, 'vps');
    Severity: Minor
    Found in src/api.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 local variables such as '$hostname'.
    Open

        $hostname = $service[$settings['PREFIX'].'_hostname'];
    Severity: Minor
    Found in src/api.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 local variables such as '$apiDetails'.
    Open

            $apiDetails = whm_api();
    Severity: Minor
    Found in src/api.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 local variables such as '$db'.
    Open

        $db = get_module_db($module);
    Severity: Minor
    Found in src/api.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 local variables such as '$whmpassword'.
    Open

            $whmpassword = $hash;
    Severity: Minor
    Found in src/api.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 $service_master is not named in camelCase.
    Open

    function api_auto_cpanel_login($id)
    {
        $return = ['status' => 'error', 'status_text' => ''];
        $module = 'webhosting';
        $custid = get_custid($GLOBALS['tf']->session->account_id, 'vps');
    Severity: Minor
    Found in src/api.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 $service_master is not named in camelCase.
    Open

    function api_auto_cpanel_login($id)
    {
        $return = ['status' => 'error', 'status_text' => ''];
        $module = 'webhosting';
        $custid = get_custid($GLOBALS['tf']->session->account_id, 'vps');
    Severity: Minor
    Found in src/api.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