vindi/vindi-woocommerce

View on GitHub

Showing 2,474 of 2,474 total issues

Avoid unused parameters such as '$post'.
Open

  function create($post_id, $post, $update, $recreated = false)
Severity: Minor
Found in src/controllers/ProductController.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

The class VindiPaymentProcessor has 1495 lines of code. Current threshold is 1000. Avoid really long classes.
Open

class VindiPaymentProcessor
{
    /**
     * Order type is invalid.
     */
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

The method get_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $vindi_product = $this->controllers->plans->create($product_id, '', '', true);
            }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'.
Open

        $matching_item = VindiHelpers::get_matching_subscription_item($subscription, $order_item);
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused local variables such as '$key'.
Open

    foreach ($order_meta as $key => $order_item) {
Severity: Minor
Found in src/utils/PaymentGateway.php by phpmd

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 method order_has_trial_and_simple_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $has_simple_product = true;
                if ($has_trial) {
                    return true;
                }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The function VindiRedirectToMyAccount() contains an exit expression.
Open

      exit;
Severity: Minor
Found in src/utils/RedirectCheckout.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

The method handle() contains an exit expression.
Open

                die($e->getMessage());
Severity: Minor
Found in src/services/Webhooks.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

Avoid unused local variables such as '$subscriptionn_id'.
Open

      throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
Severity: Minor
Found in src/services/Webhooks.php by phpmd

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 method get_plan_from_order_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $vindi_plan = get_post_meta($product->get_id(), 'vindi_plan_id', true);
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$name'.
Open

    public static function critical_dependency_missing_notice($name, $version)
Severity: Minor
Found in src/validators/Dependencies.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$data'.
Open

  private function test($data)
Severity: Minor
Found in src/services/Webhooks.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

The method bill_paid uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $vindi_subscription_id = $data->bill->subscription->id;
                $cycle = $data->bill->period->cycle;
                $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle);
            }
Severity: Minor
Found in src/services/Webhooks.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$order_items'.
Open

    protected function build_interest_rate_item($order_items)
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$version'.
Open

    public static function critical_dependency_missing_notice($name, $version)
Severity: Minor
Found in src/validators/Dependencies.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_level3_data_from_order'.
Open

      $discount_amount     = VindiHelpers::get_vindi_amount($item->get_subtotal() - $item->get_total(), $currency);
Severity: Minor
Found in src/utils/PaymentGateway.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method add_additional_items uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $order_items[] = $this->build_product_from_order_item($order_type, $product);
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'build_shipping_item'.
Open

            $wc_subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused local variables such as '$woocommerce'.
Open

    global $woocommerce;
Severity: Minor
Found in src/utils/InterestPriceHandler.php by phpmd

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

Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'.
Open

        $subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Severity
Category
Status
Source
Language