vindi/vindi-woocommerce

View on GitHub

Showing 60 of 2,474 total issues

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);
        }
Severity: Minor
Found in src/utils/SubscriptionStatusHandler.php - About 45 mins to fix

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 build_sign_up_fee_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function build_sign_up_fee_item($order_items)
    {
        foreach ($order_items as $order_item) {
            if (!is_object($order_item) || !method_exists($order_item, 'get_product')) {
                continue;
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 45 mins to fix

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_cycle_from_product_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function get_cycle_from_product_type($item)
    {
        $cycles = null;
        $product = is_object($item) && method_exists($item, 'get_product') ? $item->get_product() : false;

Severity: Minor
Found in src/utils/PaymentProcessor.php - About 45 mins to fix

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 check_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function check_response($response)
    {
        if (isset($response['errors']) && !empty($response['errors'])) {
            foreach ($response['errors'] as $error) {
                $message = $this->get_error_message($error);
Severity: Minor
Found in src/services/Api.php - About 45 mins to fix

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 process_refund has a Cognitive Complexity of 7 (exceeds 5 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);
Severity: Minor
Found in src/utils/PaymentGateway.php - About 35 mins to fix

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_plan_from_order_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_plan_from_order_item($order_item)
    {
        $product = $order_item->get_product();

        if (isset($order_item['variation_id']) && $order_item['variation_id'] != 0) {
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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 build_product_items_for_subscription has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function build_product_items_for_subscription($order_item)
    {
        $plan_cycles = $this->get_cycle_from_product_type($order_item);
        $product_item = array(
            'product_id' => $order_item['vindi_id'],
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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 build_shipping_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function build_shipping_item($order_items)
    {
        $shipping_item = [];
        $shipping_method = $this->order->get_shipping_method();
        $get_total_shipping = $this->order->get_shipping_total();
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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_product has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_product($order_item)
    {

        $product = $order_item->get_product();
        $product_id = $order_item->get_id();
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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);
        }
Severity: Minor
Found in src/utils/SubscriptionStatusHandler.php - About 35 mins to fix

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 isSubscriptionActive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  public function isSubscriptionActive($subscription_id)
  {
    $subscription_id = filter_var($subscription_id, FILTER_SANITIZE_NUMBER_INT);
    if (isset($this->recentRequest)
      && $this->recentRequest['id'] == $subscription_id) {
Severity: Minor
Found in src/routes/RoutesApi.php - About 35 mins to fix

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 too many return statements within this method.
Open

    return $response;
Severity: Major
Found in src/controllers/PlansController.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return array(
            'product' => $variations_products,
            'plan' => $variations_plans,
          );
    Severity: Major
    Found in src/controllers/PlansController.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $createdProduct;
      Severity: Major
      Found in src/controllers/ProductController.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return $response;
        Severity: Major
        Found in src/controllers/PlansController.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $cycles > 0 ? $cycles : null;
          Severity: Major
          Found in src/utils/PaymentProcessor.php - About 30 mins to fix

            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);
            Severity: Minor
            Found in src/utils/SubscriptionStatusHandler.php - About 25 mins to fix

            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 coupon_supports_product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function coupon_supports_product($order_item, $coupon)
                {
                    $product_id = $order_item->get_product()->get_id();
                    $included_products = $coupon->get_product_ids();
                    $excluded_products = $coupon->get_excluded_product_ids();
            Severity: Minor
            Found in src/utils/PaymentProcessor.php - About 25 mins to fix

            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 calculate_cost has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              public function calculate_cost($cart) {
                global $woocommerce;
                    if (is_admin() && !is_ajax()) {
                      return;
                    }
            Severity: Minor
            Found in src/utils/InterestPriceHandler.php - About 25 mins to fix

            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 bill_paid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function bill_paid($data)
                {
                    try {
                        if (empty($data->bill->subscription)) {
                          $order = $this->find_order_by_id($data->bill->code);
            Severity: Minor
            Found in src/services/Webhooks.php - About 25 mins to fix

            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

            Severity
            Category
            Status
            Source
            Language