mercadopago/cart-virtuemart

View on GitHub

Showing 38 of 38 total issues

Method postPreferenceCheckout has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function postPreferenceCheckout($cart, $order, $payment_method){

        $this->logInfo('--------------------------------------', 'debug');
        $this->logInfo('Create Preference: ' . date("Y-m-d H:i:s"), 'debug');
        $this->logInfo('Order Data: ' . json_encode($order['details']), 'debug');
Severity: Major
Found in mercadopago/mercadopago.php - About 2 hrs to fix

    Method postCreditCardPaymentV1 has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function postCreditCardPaymentV1($cart, $order, $payment_method){
    
            // DELETE
            // require(VMPATH_ROOT . DS.'plugins'.DS.'vmpayment'.DS.'mercadopago'.DS.'mercadopago'.DS.'lib'.DS.'test.php');
    
    
    Severity: Major
    Found in mercadopago/mercadopago.php - About 2 hrs to fix

      Method exec has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function exec($request) {
          // private static function exec($method, $uri, $data, $content_type) {
      
              $connect = self::build_request($request);
      
      
      Severity: Major
      Found in mercadopago/mercadopago/lib/mercadopago.php - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if($payment_result['status'] == 200 || $payment_result['status'] == 201 ){
                    $this->_closeCheckout($payment_method, $payment_result['response']['id']);
        
                    // empty car
                    $this->emptyCart();
        Severity: Major
        Found in mercadopago/mercadopago.php and 1 other location - About 1 hr to fix
        mercadopago/mercadopago.php on lines 618..635

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if($payment_result['status'] == 200 || $payment_result['status'] == 201 ){
                    $this->_closeCheckout($payment_method, $payment_result['response']['id']);
        
                    // empty car
                    $this->emptyCart();
        Severity: Major
        Found in mercadopago/mercadopago.php and 1 other location - About 1 hr to fix
        mercadopago/mercadopago.php on lines 665..682

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            function __construct(&$subject, $config) {
        
                parent::__construct($subject, $config);
        
                $this->_loggable = TRUE;
        Severity: Minor
        Found in mercadopago/mercadopago.php - About 1 hr to fix

          Function updateStatusOrder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              function updateStatusOrder($payment_method, $order_id, $status, $payment){
                  $status_http = "HTTP/1.1 200 OK";
          
                  $orderModel=VmModel::getModel('orders');
                  $order = $orderModel->getOrder($order_id);
          Severity: Minor
          Found in mercadopago/mercadopago.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 updateStatusOrder has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function updateStatusOrder($payment_method, $order_id, $status, $payment){
                  $status_http = "HTTP/1.1 200 OK";
          
                  $orderModel=VmModel::getModel('orders');
                  $order = $orderModel->getOrder($order_id);
          Severity: Minor
          Found in mercadopago/mercadopago.php - About 1 hr to fix

            Method getItemsFromCart has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function getItemsFromCart($cart, $payment_method){
                    $total_sum = 0;
                    $total_order = (float) ($cart->cartPrices['billTotal'] - $cart->cartPrices['salesPriceShipment']);
                    $items = array();
            
            
            Severity: Minor
            Found in mercadopago/mercadopago.php - About 1 hr to fix

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

                  function plgVmConfirmedOrder($cart, $order) {
              
              
                      if (!($payment_method = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
                          return NULL;
              Severity: Minor
              Found in mercadopago/mercadopago.php - About 1 hr to fix

                Method paymentNotificationBasic has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function paymentNotificationBasic($payment_method){
                        $status_http = "HTTP/1.1 200 OK";
                
                        if(isset($_REQUEST['topic']) && isset($_REQUEST['id']) && !is_null($_REQUEST['id'])){
                            if($_REQUEST['topic'] == "merchant_order"){
                Severity: Minor
                Found in mercadopago/mercadopago.php - About 1 hr to fix

                  Function overOnePaymentsIPN has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static function overOnePaymentsIPN($merchant_order){
                  
                      $total_amount = $merchant_order['total_amount'];
                      $total_paid_approved = 0;
                      $payment_return = array(
                  Severity: Minor
                  Found in mercadopago/mercadopago/helpers/mercadopago.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 postCreditCardPaymentV1 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function postCreditCardPaymentV1($cart, $order, $payment_method){
                  
                          // DELETE
                          // require(VMPATH_ROOT . DS.'plugins'.DS.'vmpayment'.DS.'mercadopago'.DS.'mercadopago'.DS.'lib'.DS.'test.php');
                  
                  
                  Severity: Minor
                  Found in mercadopago/mercadopago.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 paymentNotificationV1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function paymentNotificationV1($payment_method){
                          $status_http = "HTTP/1.1 200 OK";
                  
                          if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'payment' && isset($_REQUEST['data_id'])){
                              $payment_id = $_REQUEST['data_id'];
                  Severity: Minor
                  Found in mercadopago/mercadopago.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 checkConditions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function checkConditions($cart, $method, $cart_prices) {
                  
                          //$this->convert ($method);
                  
                          $address = (($cart->ST == 0) ? $cart->BT : $cart->ST);
                  Severity: Minor
                  Found in mercadopago/mercadopago.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 postPreferenceCheckout has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function postPreferenceCheckout($cart, $order, $payment_method){
                  
                          $this->logInfo('--------------------------------------', 'debug');
                          $this->logInfo('Create Preference: ' . date("Y-m-d H:i:s"), 'debug');
                          $this->logInfo('Order Data: ' . json_encode($order['details']), 'debug');
                  Severity: Minor
                  Found in mercadopago/mercadopago.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 getPhoneFromOrder has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function getPhoneFromOrder($order){
                          //Valida se existe telefone disponĂ­vel
                  
                          $phone = $order['details']['BT']->phone_1;
                  
                  
                  Severity: Minor
                  Found in mercadopago/mercadopago.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 $this->postPreferenceCheckout($cart, $order, $payment_method);
                  Severity: Major
                  Found in mercadopago/mercadopago.php - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language