woothemes/woocommerce

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

Summary

Maintainability
D
2 days
Test Coverage

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

/*global woocommerce_admin_meta_boxes */
jQuery( function( $ ) {

    // Scroll to first checked category
    // https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
Severity: Major
Found in assets/js/admin/meta-boxes-product.js - About 1 day to fix

    Function show_and_hide_panels has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function show_and_hide_panels() {
            var product_type    = $( 'select#product-type' ).val();
            var is_virtual      = $( 'input#_virtual:checked' ).length;
            var is_downloadable = $( 'input#_downloadable:checked' ).length;
    
    
    Severity: Minor
    Found in assets/js/admin/meta-boxes-product.js - About 1 hr to fix

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

          $( '.product_attributes' ).on( 'click', 'button.select_all_attributes', function() {
              $( this ).closest( 'td' ).find( 'select option' ).prop( 'selected', 'selected' );
              $( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
              return false;
          });
      Severity: Major
      Found in assets/js/admin/meta-boxes-product.js and 1 other location - About 2 hrs to fix
      assets/js/admin/settings.js on lines 112..116

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

      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

          $( '.product_attributes' ).on( 'click', 'button.select_no_attributes', function() {
              $( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
              $( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
              return false;
          });
      Severity: Major
      Found in assets/js/admin/meta-boxes-product.js and 1 other location - About 2 hrs to fix
      assets/js/admin/settings.js on lines 118..122

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

      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

                  $( '#product_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
                      var attachment_id = $( this ).attr( 'data-attachment_id' );
                      attachment_ids = attachment_ids + attachment_id + ',';
                  });
      Severity: Major
      Found in assets/js/admin/meta-boxes-product.js and 1 other location - About 1 hr to fix
      assets/js/admin/meta-boxes-product.js on lines 678..681

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

      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

              $( '#product_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
                  var attachment_id = $( this ).attr( 'data-attachment_id' );
                  attachment_ids = attachment_ids + attachment_id + ',';
              });
      Severity: Major
      Found in assets/js/admin/meta-boxes-product.js and 1 other location - About 1 hr to fix
      assets/js/admin/meta-boxes-product.js on lines 663..666

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

      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