vindi/vindi-woocommerce

View on GitHub

Showing 2,474 of 2,474 total issues

Function array_sort has a Cognitive Complexity of 21 (exceeds 5 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 2 hrs 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 update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  function update($user_id, $order = null)
  {
    $vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
    // Check meta Vindi ID
    if (empty($vindi_customer_id)) {
Severity: Minor
Found in src/controllers/CustomerController.php - About 2 hrs 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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  function update($post_id)
  {
    $product = wc_get_product($post_id);

    // Check if the post is of the signature type
Severity: Minor
Found in src/controllers/PlansController.php - About 2 hrs 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 init_form_fields has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function init_form_fields()
  {
    $url           = admin_url(sprintf('admin.php?page=wc-status&tab=logs&log_file=%s-%s-log', VINDI, $this->get_token()));
    $logs_url      = '<a href="' . $url . '" target="_blank">' . __('Ver Logs', VINDI) . '</a>';
    $nfe_know_more = '<a href="http://atendimento.vindi.com.br/hc/pt-br/articles/204450944-Notas-fiscais" target="_blank">' . __('Saiba mais', VINDI) . '</a>';
Severity: Major
Found in src/includes/admin/Settings.php - About 2 hrs to fix

    Method init_form_fields has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function init_form_fields()
        {
    
          $this->form_fields = array(
            'enabled' => array(
    Severity: Major
    Found in src/includes/gateways/CreditPayment.php - About 2 hrs to fix

      Method create has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function create($user_id, $order = null)
        {
      
          $customer = new WC_Customer($user_id);
      
      
      Severity: Major
      Found in src/controllers/CustomerController.php - About 2 hrs to fix

        Function getPaymentMethods has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          public function getPaymentMethods()
          {
            if (false === ($payment_methods = get_transient('vindi_payment_methods'))) {
        
              $payment_methods = array(
        Severity: Minor
        Found in src/routes/RoutesApi.php - About 2 hrs 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 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

                      Avoid using undefined variables such as '$subscriptionn_id' which will lead to PHP notices.
                      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

                      UndefinedVariable

                      Since: 2.8.0

                      Detects when a variable is used that has not been defined before.

                      Example

                      class Foo
                      {
                          private function bar()
                          {
                              // $message is undefined
                              echo $message;
                          }
                      }

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

                      Avoid using undefined variables such as '$plugin' which will lead to PHP notices.
                      Open

                                      array_push($errors, $plugin);
                      Severity: Minor
                      Found in src/validators/Dependencies.php by phpmd

                      UndefinedVariable

                      Since: 2.8.0

                      Detects when a variable is used that has not been defined before.

                      Example

                      class Foo
                      {
                          private function bar()
                          {
                              // $message is undefined
                              echo $message;
                          }
                      }

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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language