detain/myadmin-cpanel-webhosting

View on GitHub

Showing 36 of 139 total issues

File xmlapi.php has 1064 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
* cPanel XMLAPI Client Class
*
* This class allows for easy interaction with cPanel's XML-API allow functions within the XML-API to be called
Severity: Major
Found in src/xmlapi.php - About 2 days to fix

    xmlapi has 104 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class xmlapi
    {
        // should debugging statements be printed?
        private $debug            = false;
    
    
    Severity: Major
    Found in src/xmlapi.php - About 2 days to fix

      Function getActivate has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getActivate(GenericEvent $event)
          {
              if ($event['category'] == get_service_define('WEB_CPANEL')) {
                  $serviceClass = $event->getSubject();
                  myadmin_log(self::$module, 'info', 'Cpanel Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
      Severity: Minor
      Found in src/Plugin.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

      File Plugin.php has 718 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Detain\MyAdminCpanel;
      
      use Detain\Cpanel\Cpanel;
      Severity: Major
      Found in src/Plugin.php - About 1 day to fix

        Method getActivate has 311 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getActivate(GenericEvent $event)
            {
                if ($event['category'] == get_service_define('WEB_CPANEL')) {
                    $serviceClass = $event->getSubject();
                    myadmin_log(self::$module, 'info', 'Cpanel Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
        Severity: Major
        Found in src/Plugin.php - About 1 day to fix

          Function getTerminate has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getTerminate(GenericEvent $event)
              {
                  if (in_array($event['type'], [get_service_define('WEB_CPANEL'), get_service_define('WEB_WORDPRESS')])) {
                      $serviceClass = $event->getSubject();
                      myadmin_log(self::$module, 'info', 'Cpanel Termination', __LINE__, __FILE__, self::$module, $serviceClass->getId());
          Severity: Minor
          Found in src/Plugin.php - About 4 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 __construct has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public function __construct($host = null, $user = null, $password = null)
              {
                  // Check if debugging must be enabled
                  if ((defined('XMLAPI_DEBUG')) && (XMLAPI_DEBUG == '1')) {
                      $this->debug = true;
          Severity: Minor
          Found in src/xmlapi.php - About 3 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 xmlapi_query has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public function xmlapi_query($function, $vars = [])
              {
                  // Check to make sure all the data needed to perform the query is in place
                  if (!$function) {
                      throw new Exception('xmlapi_query() requires a function to be passed to it');
          Severity: Minor
          Found in src/xmlapi.php - About 3 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 getRequirements has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getRequirements(GenericEvent $event)
              {
                  /**
                   * @var \MyAdmin\Plugins\Loader $this->loader
                   */
          Severity: Major
          Found in src/Plugin.php - About 3 hrs to fix

            Method getMenu has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getMenu(GenericEvent $event)
                {
                    $menu = $event->getSubject();
                    if ($GLOBALS['tf']->ima == 'admin') {
                        function_requirements('has_acl');
            Severity: Major
            Found in src/Plugin.php - About 2 hrs to fix

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

                  public function xmlapi_query($function, $vars = [])
                  {
                      // Check to make sure all the data needed to perform the query is in place
                      if (!$function) {
                          throw new Exception('xmlapi_query() requires a function to be passed to it');
              Severity: Major
              Found in src/xmlapi.php - About 2 hrs to fix

                Method getTerminate has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getTerminate(GenericEvent $event)
                    {
                        if (in_array($event['type'], [get_service_define('WEB_CPANEL'), get_service_define('WEB_WORDPRESS')])) {
                            $serviceClass = $event->getSubject();
                            myadmin_log(self::$module, 'info', 'Cpanel Termination', __LINE__, __FILE__, self::$module, $serviceClass->getId());
                Severity: Major
                Found in src/Plugin.php - About 2 hrs to fix

                  Method getSettings has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function getSettings(GenericEvent $event)
                      {
                          /**
                           * @var \MyAdmin\Settings $settings
                           **/
                  Severity: Major
                  Found in src/Plugin.php - About 2 hrs to fix

                    Method __construct has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct($host = null, $user = null, $password = null)
                        {
                            // Check if debugging must be enabled
                            if ((defined('XMLAPI_DEBUG')) && (XMLAPI_DEBUG == '1')) {
                                $this->debug = true;
                    Severity: Minor
                    Found in src/xmlapi.php - About 1 hr to fix

                      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

                        Consider simplifying this complex logical expression.
                        Open

                                if (!isset($args['xemail']) || !isset($args['host']) || !isset($args['country']) || !isset($args['state']) || !isset($args['city']) || !isset($args['co']) || !isset($args['cod']) || !isset($args['email']) || !isset($args['pass'])) {
                                    error_log("generatessl requires that xemail, host, country, state, city, co, cod, email and pass are defined in the array passed to it");
                        
                                    return false;
                                }
                        Severity: Critical
                        Found in src/xmlapi.php - About 1 hr to fix

                          Method getDeactivate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function getDeactivate(GenericEvent $event)
                              {
                                  if (in_array($event['type'], [get_service_define('WEB_CPANEL'), get_service_define('WEB_WORDPRESS')])) {
                                      $serviceClass = $event->getSubject();
                                      myadmin_log(self::$module, 'info', 'Cpanel Deactivation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
                          Severity: Minor
                          Found in src/Plugin.php - About 1 hr to fix

                            Function setresellerpackagelimits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function setresellerpackagelimits($user, $no_limit, $package = null, $allowed = null, $number = null)
                                {
                                    if (!isset($user) || !isset($no_limit)) {
                                        error_log("setresellerpackagelimits requires that a username and no_limit are passed to it by default");
                            
                            
                            Severity: Minor
                            Found in src/xmlapi.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 getReactivate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function getReactivate(GenericEvent $event)
                                {
                                    if ($event['category'] == get_service_define('WEB_CPANEL')) {
                                        $serviceClass = $event->getSubject();
                                        $settings = get_module_settings(self::$module);
                            Severity: Minor
                            Found in src/Plugin.php - About 1 hr to fix

                              Method api1_query has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function api1_query($user, $module, $function, $args = [])
                                  {
                                      if (!isset($module) || !isset($function) || !isset($user)) {
                                          error_log("api1_query requires that a module and function are passed to it");
                              
                              
                              Severity: Minor
                              Found in src/xmlapi.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language