detain/myadmin-fantastico-licensing

View on GitHub

Showing 14 of 14 total issues

Method get_fantastico_list has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function get_fantastico_list()
{
    $category = get_service_define('FANTASTICO');
    $fantasticoIps = get_fantastico_licenses();
    $ipdata = [];
Severity: Major
Found in src/fantastico.inc.php - About 2 hrs to fix

    Function reusable_fantastico has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function reusable_fantastico()
    {
        page_title('ReUsable Fantastico Licenses');
        if ($GLOBALS['tf']->ima == 'admin') {
            $module = 'licenses';
    Severity: Minor
    Found in src/reusable_fantastico.php - About 2 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

    Function activate_fantastico has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function activate_fantastico($ipAddress, $type)
    {
        ini_set('max_execution_time', 1000); // just put a lot of time
        ini_set('default_socket_timeout', 1000); // same
        $db = get_module_db('licenses');
    Severity: Minor
    Found in src/fantastico.inc.php - About 2 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 reusable_fantastico has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function reusable_fantastico()
    {
        page_title('ReUsable Fantastico Licenses');
        if ($GLOBALS['tf']->ima == 'admin') {
            $module = 'licenses';
    Severity: Major
    Found in src/reusable_fantastico.php - About 2 hrs to fix

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

      function get_available_fantastico($type)
      {
          $db = get_module_db('licenses');
          $settings = \get_module_settings('licenses');
          $fantastico = new Fantastico(FANTASTICO_USERNAME, FANTASTICO_PASSWORD);
      Severity: Minor
      Found in src/fantastico.inc.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 fantastico_licenses_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function fantastico_licenses_list()
      {
          if ($GLOBALS['tf']->ima == 'admin') {
              $table = new \TFTable();
              $table->set_title('Fantastico License List');
      Severity: Minor
      Found in src/fantastico_licenses_list.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 activate_fantastico has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function activate_fantastico($ipAddress, $type)
      {
          ini_set('max_execution_time', 1000); // just put a lot of time
          ini_set('default_socket_timeout', 1000); // same
          $db = get_module_db('licenses');
      Severity: Minor
      Found in src/fantastico.inc.php - About 1 hr to fix

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

                            ->setKey($response['licenseid'])
        Severity: Minor
        Found in src/Plugin.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

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

        function get_fantastico_list()
        {
            $category = get_service_define('FANTASTICO');
            $fantasticoIps = get_fantastico_licenses();
            $ipdata = [];
        Severity: Minor
        Found in src/fantastico.inc.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

        Missing class import via use statement (line '63', column '22').
        Open

                $table = new \TFTable();
        Severity: Minor
        Found in src/reusable_fantastico.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 '15', column '22').
        Open

                $table = new \TFTable();
        Severity: Minor
        Found in src/fantastico_licenses_list.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 '$response'.
        Open

                            ->setKey($response['licenseid'])
        Severity: Minor
        Found in src/Plugin.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 '$frequency'.
        Open

                $frequency = 1;
        Severity: Minor
        Found in src/reusable_fantastico.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 '$serviceCost'.
        Open

                            $serviceCost = $serviceTypes[$type]['services_cost'];
        Severity: Minor
        Found in src/reusable_fantastico.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

        Severity
        Category
        Status
        Source
        Language