detain/myadmin-directadmin-licensing

View on GitHub
src/directadmin.inc.php

Summary

Maintainability
D
3 days
Test Coverage

Function directadmin_get_best_type has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

function directadmin_get_best_type($module, $packageId, $order = false, $extra = false)
{
    $types = get_directadmin_license_types();
    $db = get_module_db($module);
    $found = false;
Severity: Minor
Found in src/directadmin.inc.php - About 5 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

File directadmin.inc.php has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
* DirectAdmin Related Functionality
* @author Joe Huss <detain@interserver.net>
Severity: Minor
Found in src/directadmin.inc.php - About 5 hrs to fix

    Method directadmin_get_best_type has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function directadmin_get_best_type($module, $packageId, $order = false, $extra = false)
    {
        $types = get_directadmin_license_types();
        $db = get_module_db($module);
        $found = false;
    Severity: Major
    Found in src/directadmin.inc.php - About 3 hrs to fix

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

      function directadmin_req($page, $post = '', $options = false)
      {
          require_once __DIR__.'/../../../workerman/statistics/Applications/Statistics/Clients/StatisticClient.php';
      
          if ($options === false) {
      Severity: Minor
      Found in src/directadmin.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 activate_directadmin has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function activate_directadmin($ipAddress, $ostype, $pass, $email, $name, $domain = '', $custid = null)
      {
          myadmin_log('licenses', 'info', "Called activate_directadmin({$ipAddress}, {$ostype}, {$pass}, {$email}, {$name}, {$domain})", __LINE__, __FILE__);
          $settings = \get_module_settings('licenses');
          $license = get_directadmin_license_by_ip($ipAddress);
      Severity: Major
      Found in src/directadmin.inc.php - About 2 hrs to fix

        Method directadmin_req has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function directadmin_req($page, $post = '', $options = false)
        {
            require_once __DIR__.'/../../../workerman/statistics/Applications/Statistics/Clients/StatisticClient.php';
        
            if ($options === false) {
        Severity: Minor
        Found in src/directadmin.inc.php - About 1 hr to fix

          Method deactivate_directadmin has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function deactivate_directadmin($ipAddress)
          {
              $module = 'licenses';
              $response = get_directadmin_licenses();
              foreach ($response as $idx => $data) {
          Severity: Minor
          Found in src/directadmin.inc.php - About 1 hr to fix

            Function directadmin_modify_os has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function directadmin_modify_os($lid, $os)
            {
                if ($lid) {
                    $licenses = get_directadmin_licenses();
                    $os_string = directadmin_get_os_list();
            Severity: Minor
            Found in src/directadmin.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

            Method activate_directadmin has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function activate_directadmin($ipAddress, $ostype, $pass, $email, $name, $domain = '', $custid = null)
            Severity: Major
            Found in src/directadmin.inc.php - About 50 mins to fix

              Function deactivate_directadmin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function deactivate_directadmin($ipAddress)
              {
                  $module = 'licenses';
                  $response = get_directadmin_licenses();
                  foreach ($response as $idx => $data) {
              Severity: Minor
              Found in src/directadmin.inc.php - About 35 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

              Function activate_directadmin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function activate_directadmin($ipAddress, $ostype, $pass, $email, $name, $domain = '', $custid = null)
              {
                  myadmin_log('licenses', 'info', "Called activate_directadmin({$ipAddress}, {$ostype}, {$pass}, {$email}, {$name}, {$domain})", __LINE__, __FILE__);
                  $settings = \get_module_settings('licenses');
                  $license = get_directadmin_license_by_ip($ipAddress);
              Severity: Minor
              Found in src/directadmin.inc.php - About 35 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 '$os_list' which will lead to PHP notices.
              Open

                          $os_list[$os_exp[0]] = $os_exp[1];
              Severity: Minor
              Found in src/directadmin.inc.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 '$os_list' which will lead to PHP notices.
              Open

                          if (in_array($os, array_keys($os_list))) {
              Severity: Minor
              Found in src/directadmin.inc.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

              Missing class import via use statement (line '419', column '18').
              Open

                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 '348', column '18').
              Open

                          (new \MyAdmin\Mail())->adminMail($subject, $msg, false, 'client/client_email.tpl');
              Severity: Minor
              Found in src/directadmin.inc.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 '344', column '28').
              Open

                          $smartyE = new TFSmarty();
              Severity: Minor
              Found in src/directadmin.inc.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 '435', column '18').
              Open

                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 '$found'.
              Open

                  $found = false;
              Severity: Minor
              Found in src/directadmin.inc.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 '$idx'.
              Open

                  foreach ($response as $idx => $data) {
              Severity: Minor
              Found in src/directadmin.inc.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 $license_key is not named in camelCase.
              Open

              function activate_free_license($ipAddress, $type, $email, $hostname = '')
              {
                  myadmin_log('licenses', 'info', "Called activate_free_license($ipAddress, $type, $email, $hostname)", __LINE__, __FILE__);
                  function_requirements('class.FreeDirectAdmin');
                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 $license_key is not named in camelCase.
              Open

              function activate_free_license($ipAddress, $type, $email, $hostname = '')
              {
                  myadmin_log('licenses', 'info', "Called activate_free_license($ipAddress, $type, $email, $hostname)", __LINE__, __FILE__);
                  function_requirements('class.FreeDirectAdmin');
                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 $os_exp is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_list is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $license_key is not named in camelCase.
              Open

              function delete_free_license($lid, $type)
              {
                  myadmin_log('licenses', 'info', "Called delete_free_license($lid)", __LINE__, __FILE__);
                  function_requirements('class.FreeDirectAdmin');
                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 $license_key is not named in camelCase.
              Open

              function delete_free_license($lid, $type)
              {
                  myadmin_log('licenses', 'info', "Called delete_free_license($lid)", __LINE__, __FILE__);
                  function_requirements('class.FreeDirectAdmin');
                  $daObj = new FreeDirectAdmin('licenses', $type, false, false);
              Severity: Minor
              Found in src/directadmin.inc.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 $os_exp is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_string is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_arr is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_string is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_arr is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_list is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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 $os_exp is not named in camelCase.
              Open

              function directadmin_modify_os($lid, $os)
              {
                  if ($lid) {
                      $licenses = get_directadmin_licenses();
                      $os_string = directadmin_get_os_list();
              Severity: Minor
              Found in src/directadmin.inc.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