Showing 139 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
xmlapi
has 104 functions (exceeds 20 allowed). Consider refactoring. Open
class xmlapi
{
// should debugging statements be printed?
private $debug = false;
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());
- Read upRead up
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;
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());
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());
- Read upRead up
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;
- Read upRead up
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');
- Read upRead up
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
*/
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');
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');
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());
Method getSettings
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSettings(GenericEvent $event)
{
/**
* @var \MyAdmin\Settings $settings
**/
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;
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');
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;
}
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());
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");
- Read upRead up
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 '$header' which will lead to PHP notices. Open
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
- Read upRead up
- Exclude checks
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 '$header' which will lead to PHP notices. Open
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // Set the username and password.
- Read upRead up
- Exclude checks
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;
}
}