detain/myadmin-licenses-module

View on GitHub

Showing 18 of 125 total issues

Function api_buy_license has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

function api_buy_license($sid, $ip, $service_type, $coupon = '', $use_prepay = null)
{
    if (null === $use_prepay) {
        $use_prepay = true;
        $prepay_low_funds_triggers_error = false;
Severity: Minor
Found in src/api.php - About 1 day 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 api_buy_license has 216 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function api_buy_license($sid, $ip, $service_type, $coupon = '', $use_prepay = null)
{
    if (null === $use_prepay) {
        $use_prepay = true;
        $prepay_low_funds_triggers_error = false;
Severity: Major
Found in src/api.php - About 1 day to fix

    File api.php has 418 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
    * API License Functions
    *
    * @author Joe Huss <detain@interserver.net>
    Severity: Minor
    Found in src/api.php - About 6 hrs to fix

      Method api_cancel_license_ip has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function api_cancel_license_ip($sid, $ip, $service_type)
      {
          $service_type = (int)$service_type;
          myadmin_log('api', 'info', "api_cancel_license_ip('{$sid}', '{$ip}', {$service_type}) called", __LINE__, __FILE__);
          $module = 'licenses';
      Severity: Major
      Found in src/api.php - About 2 hrs to fix

        Method api_change_license_ip has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function api_change_license_ip($sid, $oldip, $newip)
        {
            $GLOBALS['tf']->session->sessionid = $sid;
            $module = 'licenses';
            $settings = get_module_settings($module);
        Severity: Minor
        Found in src/api.php - About 1 hr to fix

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

          function api_change_license_ip_by_id($sid, $id, $newip)
          {
              $id = (int)$id;
              $GLOBALS['tf']->session->sessionid = $sid;
              $module = 'licenses';
          Severity: Minor
          Found in src/api.php - About 1 hr to fix

            Function api_cancel_license_ip has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            function api_cancel_license_ip($sid, $ip, $service_type)
            {
                $service_type = (int)$service_type;
                myadmin_log('api', 'info', "api_cancel_license_ip('{$sid}', '{$ip}', {$service_type}) called", __LINE__, __FILE__);
                $module = 'licenses';
            Severity: Minor
            Found in src/api.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 api_cancel_license has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function api_cancel_license($sid, $id)
            {
                $module = 'licenses';
                $id = (int)$id;
                $db = get_module_db($module);
            Severity: Minor
            Found in src/api.php - About 1 hr to fix

              Method loadProcessing has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function loadProcessing(GenericEvent $event)
                  {
                      /**
                       * @var \ServiceHandler $service
                       */
              Severity: Minor
              Found in src/Plugin.php - About 1 hr to fix

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

                function api_change_license_ip($sid, $oldip, $newip)
                {
                    $GLOBALS['tf']->session->sessionid = $sid;
                    $module = 'licenses';
                    $settings = get_module_settings($module);
                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

                Method api_buy_license_prepay has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function api_buy_license_prepay($sid, $ip, $service_type, $coupon = '', $use_prepay = null)
                Severity: Minor
                Found in src/api.php - About 35 mins to fix

                  Method api_buy_license has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function api_buy_license($sid, $ip, $service_type, $coupon = '', $use_prepay = null)
                  Severity: Minor
                  Found in src/api.php - About 35 mins to fix

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

                    function api_change_license_ip_by_id($sid, $id, $newip)
                    {
                        $id = (int)$id;
                        $GLOBALS['tf']->session->sessionid = $sid;
                        $module = 'licenses';
                    Severity: Minor
                    Found in src/api.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 too many return statements within this method.
                    Open

                        return $return;
                    Severity: Major
                    Found in src/api.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $return;
                      Severity: Major
                      Found in src/api.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $return;
                        Severity: Major
                        Found in src/api.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                              return $return;
                          Severity: Major
                          Found in src/api.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return $return;
                            Severity: Major
                            Found in src/api.php - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language