Function order_fully_refunded
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function order_fully_refunded($order)
{
if (!is_object($order)) {
$order = wc_get_order($order);
}
- 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 order_canceled
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function order_canceled($order)
{
if (!is_object($order)) {
$order = wc_get_order($order);
}
- 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 filter_pre_status
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function filter_pre_status($wc_subscription, $new_status, $old_status)
{
switch ($new_status) {
case 'on-hold':
$this->suspend_status($wc_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
Avoid unused local variables such as '$item'. Open
foreach ($vindi_order as $key => $item) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The property $vindi_settings is not named in camelCase. Open
class VindiSubscriptionStatusHandler
{
/**
* @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
Only one argument is allowed per line in a multi-line function call Open
), array('a' => array('href' => true))));
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
$subscriptions = wcs_get_subscriptions_for_order(wcs_get_objects_property($order, 'id'), array('order_type' => array('parent', 'renewal')));
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
sprintf('<a href="%s">', esc_url(wcs_get_edit_post_link(wcs_get_objects_property($order, 'id')))),
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
if (wcs_get_objects_property($order, 'id') == $latest_order && $subscription->can_be_updated_to('cancelled')) {
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
), array('a' => array('href' => true))));
- Exclude checks
Multi-line function call not indented correctly; expected 20 spaces but found 24 Open
), array('a' => array('href' => true))));
- Exclude checks