gocodebox/lifterlms

View on GitHub
assets/js/llms-metabox-product.js

Summary

Maintainability
F
4 days
Test Coverage

Function metabox_product has 409 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    window.llms.metabox_product = function() {

        /**
         * jQuery obj for the main $( '#llms-access-plans' ) element.
         *
Severity: Major
Found in assets/js/llms-metabox-product.js - About 2 days to fix

    File llms-metabox-product.js has 415 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Product Options MetaBox.
     *
     * Displays on Course & Membership Post Types.
     *
    Severity: Minor
    Found in assets/js/llms-metabox-product.js - About 5 hrs to fix

      Function bind has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              this.bind = function() {
      
                  var self = this;
      
                  setTimeout( function() {
      Severity: Major
      Found in assets/js/llms-metabox-product.js - About 4 hrs to fix

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

                this.controller_change = function( $el ) {
        
                    var id        = $el.attr( 'data-controller-id' ),
                        val       = $el.val(),
                        $form     = $el.closest( '.llms-access-plan' ),
        Severity: Minor
        Found in assets/js/llms-metabox-product.js - About 1 hr to fix

          Function save_plans has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  this.save_plans = function() {
          
                      var self = this;
          
                      self.$plans.find( '.llms-access-plan' ).not( '#llms-new-access-plan-model' ).each( function() {
          Severity: Minor
          Found in assets/js/llms-metabox-product.js - About 1 hr to fix

            Function init has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    this.init = function( skip_dep_checks ) {
            
                        var self = this;
            
                        self.$plans = $( '#llms-access-plans' );
            Severity: Minor
            Found in assets/js/llms-metabox-product.js - About 1 hr to fix

              Function delete_plan has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      this.delete_plan = function( $btn ) {
              
                          var self    = this,
                              $plan   = $btn.closest( '.llms-access-plan' ),
                              plan_id = $plan.attr( 'data-id' ),
              Severity: Minor
              Found in assets/js/llms-metabox-product.js - About 1 hr to fix

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

                            $toggle.on( 'click', function( e ) {
                                e.preventDefault();
                                $radios.slideDown( 'fast' );
                                $toggle.hide();
                            } );
                Severity: Minor
                Found in assets/js/llms-metabox-product.js and 1 other location - About 40 mins to fix
                assets/js/llms-metabox-product.js on lines 322..326

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

                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

                            $cancel.on( 'click', function( e ) {
                                e.preventDefault();
                                $radios.slideUp( 'fast' );
                                $toggle.show();
                            } );
                Severity: Minor
                Found in assets/js/llms-metabox-product.js and 1 other location - About 40 mins to fix
                assets/js/llms-metabox-product.js on lines 309..313

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

                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