mercadopago/cart-wp-commerce

View on GitHub

Showing 163 of 163 total issues

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

    if ( $form_labels == '' ) {
        $form_labels = array(
            "form" => array(
                "payment_approved" => __( "Payment <strong>approved</strong>.", "wpecomm-mercadopago-module" ),
                "payment_in_process" => __( "Your payment under <strong>review</strong>.", "wpecomm-mercadopago-module" ),
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-custom.php and 1 other location - About 4 days to fix
wpecomm-mercado-pago-module/mercadopago-custom.php on lines 68..133

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 779.

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

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

        if ( $form_labels == '' ) {
            $form_labels = array(
                "form" => array(
                    "payment_approved" => __( "Payment <strong>approved</strong>.", "wpecomm-mercadopago-module" ),
                    "payment_in_process" => __( "Your payment under <strong>review</strong>.", "wpecomm-mercadopago-module" ),
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-custom.php and 1 other location - About 4 days to fix
wpecomm-mercado-pago-module/mercadopago-custom.php on lines 1137..1202

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 779.

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

    private static function build_request($request) {
        if (!extension_loaded ("curl")) {
            throw new MercadoPagoException("cURL extension not found. You need to enable cURL in your php.ini or another configuration you have.");
        }

Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-lib/mercadopago.php and 1 other location - About 4 days to fix
wpecomm-mercado-pago-module/mercadopago-lib/mercadopago.php on lines 516..593

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 744.

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

    private static function build_request_ml($request) {
        if (!extension_loaded ("curl")) {
            throw new MercadoPagoException("cURL extension not found. You need to enable cURL in your php.ini or another configuration you have.");
        }

Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-lib/mercadopago.php and 1 other location - About 4 days to fix
wpecomm-mercado-pago-module/mercadopago-lib/mercadopago.php on lines 595..672

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 744.

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 3 locations. Consider refactoring.
Open

    if ($result['is_valid'] == true) {
        try {
            // checking the currency
            if (!isSupportedCurrency_custom($result['site_id'])) {
                if (get_option('mercadopago_custom_currencyconversion') == 'inactive') {
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-custom.php and 2 other locations - About 3 days to fix
wpecomm-mercado-pago-module/mercadopago-basic.php on lines 269..311
wpecomm-mercado-pago-module/mercadopago-ticket.php on lines 650..693

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 737.

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 3 locations. Consider refactoring.
Open

    if ($result['is_valid'] == true) {
        try {
            // checking the currency
            if (!isSupportedCurrency_ticket($result['site_id'])) {
                if (get_option('mercadopago_ticket_currencyconversion') == 'inactive') {
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-ticket.php and 2 other locations - About 3 days to fix
wpecomm-mercado-pago-module/mercadopago-basic.php on lines 269..311
wpecomm-mercado-pago-module/mercadopago-custom.php on lines 788..831

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 737.

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 3 locations. Consider refactoring.
Open

    if ($result['is_valid'] == true) {
        try {
            // checking the currency
            if (!isSupportedCurrency($result['site_id'])) {
                if (get_option('mercadopago_certified_currencyconversion') == 'inactive') {
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-basic.php and 2 other locations - About 3 days to fix
wpecomm-mercado-pago-module/mercadopago-custom.php on lines 788..831
wpecomm-mercado-pago-module/mercadopago-ticket.php on lines 650..693

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 737.

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

File mercadopago-custom.php has 1371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Part of WPeComm Mercado Pago Module
 * Author - Mercado Pago
Severity: Major
Found in wpecomm-mercado-pago-module/mercadopago-custom.php - About 3 days to fix

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

            if (sizeof($wpsc_cart->cart_items) > 0) {
                foreach ($wpsc_cart->cart_items as $i => $item) {
                    if ($item->quantity > 0) {
                        $product = get_post($item->product_id);
                        $picture_url = 'https://www.mercadopago.com/org-img/MP3/home/logomp3.gif';
    Severity: Major
    Found in wpecomm-mercado-pago-module/mercadopago-ticket.php and 1 other location - About 3 days to fix
    wpecomm-mercado-pago-module/mercadopago-custom.php on lines 276..354

    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 596.

    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 (sizeof($wpsc_cart->cart_items) > 0) {
                foreach ($wpsc_cart->cart_items as $i => $item) {
                    if ($item->quantity > 0) {
                        $product = get_post($item->product_id);
                        $picture_url = 'https://www.mercadopago.com/org-img/MP3/home/logomp3.gif';
    Severity: Major
    Found in wpecomm-mercado-pago-module/mercadopago-custom.php and 1 other location - About 3 days to fix
    wpecomm-mercado-pago-module/mercadopago-ticket.php on lines 198..276

    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 596.

    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

    File mercadopago-basic.php has 1110 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Part of WPeComm Mercado Pago Module
     * Author - Mercado Pago
    Severity: Major
    Found in wpecomm-mercado-pago-module/mercadopago-basic.php - About 2 days to fix

      File mercadopago-ticket.php has 990 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      /**
       * Part of WPeComm Mercado Pago Module
       * Author - Mercado Pago
      Severity: Major
      Found in wpecomm-mercado-pago-module/mercadopago-ticket.php - About 2 days to fix

        Method form_mercadopago_basic has 309 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function form_mercadopago_basic() {
            global $wpdb, $wpsc_gateways;
        
            $result = validateCredentials(
                get_option('mercadopago_certified_clientid'),
        Severity: Major
        Found in wpecomm-mercado-pago-module/mercadopago-basic.php - About 1 day to fix

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

                      $form_labels = array(
                          "form" => array(
                              "issuer_selection" => __( 'Please, select the ticket issuer of your preference.', 'wpecomm-mercadopago-module' ),
                              "payment_instructions" => __( 'Click [Place order] button. The ticket will be generated and you will be redirected to print it.', 'wpecomm-mercadopago-module' ),
                              "ticket_note" => __( 'Important - The order will be confirmed only after the payment approval.', 'wpecomm-mercadopago-module' ),
          Severity: Major
          Found in wpecomm-mercado-pago-module/mercadopago-ticket.php and 1 other location - About 1 day to fix
          wpecomm-mercado-pago-module/mercadopago-ticket.php on lines 615..641

          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 335.

          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

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

              $form_labels = array(
                  "form" => array(
                      "issuer_selection" => __( 'Please, select the ticket issuer of your preference.', 'wpecomm-mercadopago-module' ),
                      "payment_instructions" => __( 'Click [Place order] button. The ticket will be generated and you will be redirected to print it.', 'wpecomm-mercadopago-module' ),
                      "ticket_note" => __( 'Important - The order will be confirmed only after the payment approval.', 'wpecomm-mercadopago-module' ),
          Severity: Major
          Found in wpecomm-mercado-pago-module/mercadopago-ticket.php and 1 other location - About 1 day to fix
          wpecomm-mercado-pago-module/mercadopago-ticket.php on lines 70..96

          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 335.

          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 form_mercadopago_custom has 280 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function form_mercadopago_custom() {
              global $wpdb, $wpsc_gateways;
          
              // labels
              $form_labels = array(
          Severity: Major
          Found in wpecomm-mercado-pago-module/mercadopago-custom.php - About 1 day to fix

            Function function_mercadopago_basic has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
            Open

            function function_mercadopago_basic($seperator, $sessionid) {
            
                global $wpdb, $wpsc_cart;
            
                // this grabs the purchase log id from the database that refers to the $sessionid
            Severity: Minor
            Found in wpecomm-mercado-pago-module/mercadopago-basic.php - About 1 day 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 function_mercadopago_basic has 215 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function function_mercadopago_basic($seperator, $sessionid) {
            
                global $wpdb, $wpsc_cart;
            
                // this grabs the purchase log id from the database that refers to the $sessionid
            Severity: Major
            Found in wpecomm-mercado-pago-module/mercadopago-basic.php - About 1 day to fix

              Method form_mercadopago_ticket has 212 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function form_mercadopago_ticket() {
                  global $wpdb, $wpsc_gateways;
              
                  // labels
                  $form_labels = array(
              Severity: Major
              Found in wpecomm-mercado-pago-module/mercadopago-ticket.php - About 1 day to fix

                File MPv1.js has 520 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // MPv1
                // Handlers Form Mercado Pago v1
                
                (function (){
                
                
                Severity: Major
                Found in wpecomm-mercado-pago-module/mercadopago-lib/MPv1.js - About 1 day to fix
                  Severity
                  Category
                  Status
                  Source
                  Language