Showing 2,474 of 2,474 total issues
Method process_refund
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process_refund($order_id, $amount = null, $reason = '') {
$order_id = filter_var($order_id, FILTER_SANITIZE_NUMBER_INT);
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
$reason = sanitize_text_field($reason);
$order = wc_get_order($order_id);
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update($post_id)
{
$product = wc_get_product($post_id);
// Check if the post is NOT of the subscription type
Function get_installments
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function get_installments()
{
if ($this->is_single_order())
return $this->installments;
- 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 create
has a Cognitive Complexity of 10 (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) {
return;
- 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 get_matching_subscription_item
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function get_matching_subscription_item($subscription, $order_item, $match_type = 'match_attributes')
{
$matching_item = false;
if ('match_attributes' === $match_type) {
- 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 __construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
{
$this->id = 'vindi-bank-slip';
$this->icon = apply_filters('vindi_woocommerce_bank_slip_icon', '');
$this->method_title = __('Vindi - Boleto Bancário', VINDI);
Method array_sort
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = array();
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class FieldValidator {
- Exclude checks
Function test_api_key
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function test_api_key($api_key)
{
delete_transient('vindi_merchant');
$url = $this->base_path() . 'merchant';
- 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 get_matching_subscription
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function get_matching_subscription($order, $order_item)
{
$subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
$matching_subscription = null;
foreach ($subscriptions as $subscription) {
- 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 property $current_plan is not named in camelCase. Open
class VindiApi
{
/**
* @var string
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $vindi_settings is not named in camelCase. Open
class CustomerController
{
/**
* @var VindiSettings
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $vindi_settings is not named in camelCase. Open
class VindiBankSlipGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public function findCustomerById($id)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $on. Configured minimum length is 3. Open
public static function array_sort($array, $on, $order=SORT_ASC)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $max_installments is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $interest_rate is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $main_logger is not named in camelCase. Open
class VindiLogger
{
/**
* identifier to WC_Logger
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $vindi_settings is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $verify_method is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}