woothemes/woocommerce

View on GitHub
assets/js/admin/meta-boxes-product-variation.js

Summary

Maintainability
F
3 days
Test Coverage

File meta-boxes-product-variation.js has 666 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global wp, woocommerce_admin_meta_boxes_variations, woocommerce_admin, accounting */
jQuery( function( $ ) {
    'use strict';

    /**
Severity: Major
Found in assets/js/admin/meta-boxes-product-variation.js - About 1 day to fix

    Function do_variation_action has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            do_variation_action: function() {
                var do_variation_action = $( 'select.variation_actions' ).val(),
                    data       = {},
                    changes    = 0,
                    value;
    Severity: Major
    Found in assets/js/admin/meta-boxes-product-variation.js - About 3 hrs to fix

      Function variations_loaded has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              variations_loaded: function( event, needsUpdate ) {
                  needsUpdate = needsUpdate || false;
      
                  var wrapper = $( '#woocommerce-product-data' );
      
      
      Severity: Major
      Found in assets/js/admin/meta-boxes-product-variation.js - About 2 hrs to fix

        Function add_image has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                add_image: function( event ) {
                    var $button = $( this ),
                        post_id = $button.attr( 'rel' ),
                        $parent = $button.closest( '.upload_image' );
        
        
        Severity: Minor
        Found in assets/js/admin/meta-boxes-product-variation.js - About 1 hr to fix

          Function remove_variation has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  remove_variation: function() {
                      wc_meta_boxes_product_variations_ajax.check_for_changes();
          
                      if ( window.confirm( woocommerce_admin_meta_boxes_variations.i18n_remove_variation ) ) {
                          var variation     = $( this ).attr( 'rel' ),
          Severity: Minor
          Found in assets/js/admin/meta-boxes-product-variation.js - About 1 hr to fix

            Function set_paginav has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    set_paginav: function( qty ) {
                        var wrapper          = $( '#variable_product_options' ).find( '.woocommerce_variations' ),
                            new_qty          = wc_meta_boxes_product_variations_pagenav.update_variations_count( qty ),
                            toolbar          = $( '#variable_product_options' ).find( '.toolbar' ),
                            variation_action = $( '.variation_actions' ),
            Severity: Minor
            Found in assets/js/admin/meta-boxes-product-variation.js - About 1 hr to fix

              Function link_all_variations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      link_all_variations: function() {
                          wc_meta_boxes_product_variations_ajax.check_for_changes();
              
                          if ( window.confirm( woocommerce_admin_meta_boxes_variations.i18n_link_all_variations ) ) {
                              wc_meta_boxes_product_variations_ajax.block();
              Severity: Minor
              Found in assets/js/admin/meta-boxes-product-variation.js - About 1 hr to fix

                Avoid too many return statements within this function.
                Open

                                        return;
                Severity: Major
                Found in assets/js/admin/meta-boxes-product-variation.js - About 30 mins to fix

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

                          variable_is_virtual: function() {
                              $( this ).closest( '.woocommerce_variation' ).find( '.hide_if_variation_virtual' ).show();
                  
                              if ( $( this ).is( ':checked' ) ) {
                                  $( this ).closest( '.woocommerce_variation' ).find( '.hide_if_variation_virtual' ).hide();
                  Severity: Major
                  Found in assets/js/admin/meta-boxes-product-variation.js and 1 other location - About 2 hrs to fix
                  assets/js/admin/meta-boxes-product-variation.js on lines 41..47

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

                  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

                          variable_is_downloadable: function() {
                              $( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_downloadable' ).hide();
                  
                              if ( $( this ).is( ':checked' ) ) {
                                  $( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_downloadable' ).show();
                  Severity: Major
                  Found in assets/js/admin/meta-boxes-product-variation.js and 1 other location - About 2 hrs to fix
                  assets/js/admin/meta-boxes-product-variation.js on lines 52..58

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

                  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

                              $( '#variable_product_options' )
                                  .on( 'change', 'input.variable_is_downloadable', this.variable_is_downloadable )
                                  .on( 'change', 'input.variable_is_virtual', this.variable_is_virtual )
                                  .on( 'change', 'input.variable_manage_stock', this.variable_manage_stock )
                                  .on( 'click', 'button.notice-dismiss', this.notice_dismiss )
                  Severity: Major
                  Found in assets/js/admin/meta-boxes-product-variation.js and 1 other location - About 2 hrs to fix
                  assets/js/admin/meta-boxes-order.js on lines 270..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 80.

                  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

                  There are no issues that match your filters.

                  Category
                  Status