Showing 2,403 of 2,403 total issues
File PaymentProcessor.php
has 949 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace VindiPaymentGateways;
use DateTime;
VindiPaymentProcessor
has 62 functions (exceeds 20 allowed). Consider refactoring. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
Method create
has 155 lines of code (exceeds 25 allowed). Consider refactoring. Open
function create($post_id, $post, $update, $recreated = false)
{
// Check if the post is a draft
if (strpos(get_post_status($post_id), 'draft') !== false) {
Method update
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update($post_id)
{
$product = wc_get_product($post_id);
// Check if the post is of the signature type
File Webhooks.php
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace VindiPaymentGateways;
use WC_Subscriptions_Manager;
Function create
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function create($post_id, $post, $update, $recreated = false)
{
// Check if the post is a draft
if (strpos(get_post_status($post_id), 'draft') !== false) {
- 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 PlansController.php
has 349 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace VindiPaymentGateways;
/**
VindiRoutes
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class VindiRoutes
{
/**
* @var VindiSettings
File RoutesApi.php
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace VindiPaymentGateways;
class VindiRoutes
Function process_order
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function process_order()
{
$this->check_trial_and_single_product();
$customer = $this->get_customer();
$order_items = $this->order->get_items();
- 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
The class PlansController has an overall complexity of 70 which is very high. The configured complexity threshold is 50. Open
class PlansController
{
/**
* @var array
*/
- Exclude checks
The class VindiPaymentProcessor has 45 non-getter- and setter-methods. Consider refactoring VindiPaymentProcessor to keep number of methods under 25. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class VindiPaymentProcessor has an overall complexity of 234 which is very high. The configured complexity threshold is 50. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- Exclude checks
The class CustomerController has an overall complexity of 53 which is very high. The configured complexity threshold is 50. Open
class CustomerController
{
/**
* @var VindiSettings
- Exclude checks
The class VindiRoutes has an overall complexity of 77 which is very high. The configured complexity threshold is 50. Open
class VindiRoutes
{
/**
* @var VindiSettings
- Exclude checks
The class VindiRoutes has 23 public methods. Consider refactoring VindiRoutes to keep number of public methods under 10. Open
class VindiRoutes
{
/**
* @var VindiSettings
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class VindiWebhooks has an overall complexity of 74 which is very high. The configured complexity threshold is 50. Open
class VindiWebhooks
{
/**
* @var VindiSettings
*/
- Exclude checks
Method update
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
// Check meta Vindi ID
if (empty($vindi_customer_id)) {
Method process_order
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process_order()
{
$this->check_trial_and_single_product();
$customer = $this->get_customer();
$order_items = $this->order->get_items();
VindiWebhooks
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class VindiWebhooks
{
/**
* @var VindiSettings
*/