detain/myadmin-ips-vps-addon

View on GitHub

Showing 4 of 12 total issues

Function doEnable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
    {
        $serviceInfo = $serviceOrder->getServiceInfo();
        $settings = get_module_settings(self::$module);
        $db = get_module_db(self::$module);
Severity: Minor
Found in src/Plugin.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

Method doEnable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
    {
        $serviceInfo = $serviceOrder->getServiceInfo();
        $settings = get_module_settings(self::$module);
        $db = get_module_db(self::$module);
Severity: Minor
Found in src/Plugin.php - About 1 hr to fix

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

    function vps_ips_check_current($addon)
    {
        $addon->db->query("select * from invoices left join repeat_invoices on repeat_invoices_custid=invoices_custid and repeat_invoices_service=invoices_service and repeat_invoices_id=invoices_extra where invoices_custid={$addon->serviceInfo[$addon->settings['PREFIX'].'_custid']} and invoices_type=1 and invoices_service={$addon->serviceInfo[$addon->settings['PREFIX'].'_id']} and invoices_description like '%Additional IP%' group by invoices_extra", __LINE__, __FILE__);
        //$addon->db->query("select repeat_invoices_id, repeat_invoices_description from repeat_invoices where repeat_invoices_description like 'Additional IP%for {$addon->settings['TBLNAME']} {$addon->serviceInfo[$addon->settings['PREFIX'].'_id']}'", __LINE__, __FILE__);
        $ips = $addon->db->num_rows();
    Severity: Minor
    Found in src/vps_ips.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

    Method vps_ips_check_current has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function vps_ips_check_current($addon)
    {
        $addon->db->query("select * from invoices left join repeat_invoices on repeat_invoices_custid=invoices_custid and repeat_invoices_service=invoices_service and repeat_invoices_id=invoices_extra where invoices_custid={$addon->serviceInfo[$addon->settings['PREFIX'].'_custid']} and invoices_type=1 and invoices_service={$addon->serviceInfo[$addon->settings['PREFIX'].'_id']} and invoices_description like '%Additional IP%' group by invoices_extra", __LINE__, __FILE__);
        //$addon->db->query("select repeat_invoices_id, repeat_invoices_description from repeat_invoices where repeat_invoices_description like 'Additional IP%for {$addon->settings['TBLNAME']} {$addon->serviceInfo[$addon->settings['PREFIX'].'_id']}'", __LINE__, __FILE__);
        $ips = $addon->db->num_rows();
    Severity: Minor
    Found in src/vps_ips.php - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language