vindi/vindi-woocommerce

View on GitHub

Showing 60 of 2,474 total issues

Function create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  function create($user_id, $order = null)
  {

    $customer = new WC_Customer($user_id);

Severity: Minor
Found in src/controllers/CustomerController.php - About 1 hr 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_tax_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function build_tax_item($order_items)
    {

        $total_tax = 0;
        $taxItem = [];
Severity: Minor
Found in src/utils/PaymentProcessor.php - About 1 hr 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

Method check has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function check()
    {
        if(!self::check_critical_dependencies()) {
            return false;
        }
Severity: Minor
Found in src/validators/Dependencies.php - About 1 hr to fix

    Method test_api_key has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public function test_api_key($api_key)
      {
        delete_transient('vindi_merchant');
    
        $url         = $this->base_path() . 'merchant';
    Severity: Minor
    Found in src/services/Api.php - About 1 hr to fix

      Method get_level3_data_from_order has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function get_level3_data_from_order($order)
        {
          // WC Versions before 3.0 don't support postcodes and are
          // incompatible with level3 data.
          if (VindiHelpers::is_wc_lt('3.0')) {
      Severity: Minor
      Found in src/utils/PaymentGateway.php - About 1 hr to fix

        Method create has 35 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) {
                  return;
        Severity: Minor
        Found in src/controllers/ProductController.php - About 1 hr to fix

          Method check_critical_dependencies has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function check_critical_dependencies()
              {
                  $critical_dependencies = [
                      [
                          'name'    => 'PHP',
          Severity: Minor
          Found in src/validators/Dependencies.php - About 1 hr to fix

            Method request has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public function request($endpoint, $method = 'POST', $data = array(), $data_to_log = null)
              {
                $url  = sprintf('%s%s', $this->base_path(), $endpoint);
                $body = $this->build_body($data);
            
            
            Severity: Minor
            Found in src/services/Api.php - About 1 hr to fix

              Function order_has_trial_and_simple_product has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function order_has_trial_and_simple_product()
                  {
                      $has_trial = false;
                      $has_simple_product = false;
                      $order_items = $this->order->get_items();
              Severity: Minor
              Found in src/utils/PaymentProcessor.php - About 1 hr 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

              Method bill_paid has 30 lines of code (exceeds 25 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 1 hr to fix

                Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
                    {
                
                      global $woocommerce;
                
                
                Severity: Minor
                Found in src/includes/gateways/CreditPayment.php - About 1 hr to fix

                  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);
                  Severity: Minor
                  Found in src/utils/PaymentGateway.php - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in src/controllers/ProductController.php - About 1 hr to fix

                      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;
                      
                      
                      Severity: Minor
                      Found in src/includes/gateways/CreditPayment.php - About 1 hr 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 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;
                      Severity: Minor
                      Found in src/controllers/ProductController.php - About 1 hr 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_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) {
                      Severity: Minor
                      Found in src/services/VindiHelpers.php - About 1 hr 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

                      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);
                      Severity: Minor
                      Found in src/includes/gateways/BankSlipPayment.php - About 1 hr to fix

                        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();
                          
                        Severity: Minor
                        Found in src/services/VindiHelpers.php - About 1 hr to fix

                          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';
                          Severity: Minor
                          Found in src/services/Api.php - About 55 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_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) {
                          Severity: Minor
                          Found in src/services/VindiHelpers.php - About 55 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