madbob/GASdottoNG

View on GitHub
code/resources/assets/js/bookings.js

Summary

Maintainability
F
3 days
Test Coverage

Function updateBookingQuantities has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    static updateBookingQuantities(dynamic_data, container, action)
    {
        for (let [product_id, product_meta] of Object.entries(dynamic_data)) {
            var inputbox = $('input[name="' + product_id + '"]', container);
            inputbox.closest('tr').find('.booking-product-price span').text(utils.priceRound(product_meta.total));
Severity: Minor
Found in code/resources/assets/js/bookings.js - About 7 hrs 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 init has 183 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static init(container)
    {
        $('.bookingSearch', container).each((index, item) => {
            var input = $(item);

Severity: Major
Found in code/resources/assets/js/bookings.js - About 7 hrs to fix

    File bookings.js has 392 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import utils from "./utils";
    import Modifiers from "./modifiers";
    
    class Bookings
    {
    Severity: Minor
    Found in code/resources/assets/js/bookings.js - About 5 hrs to fix

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

          static updateBookingQuantities(dynamic_data, container, action)
          {
              for (let [product_id, product_meta] of Object.entries(dynamic_data)) {
                  var inputbox = $('input[name="' + product_id + '"]', container);
                  inputbox.closest('tr').find('.booking-product-price span').text(utils.priceRound(product_meta.total));
      Severity: Major
      Found in code/resources/assets/js/bookings.js - About 2 hrs to fix

        Function bookingTotal has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static bookingTotal(editor) {
                var form = $(editor).closest('form');
                var data = this.serializeBooking(form);
                var url = form.attr('data-dynamic-url');
        
        
        Severity: Minor
        Found in code/resources/assets/js/bookings.js - About 1 hr to fix

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

                      success: (data) => {
                          if (data.hasOwnProperty('status') && data.status == 'error') {
                              utils.displayServerError(null, data);
                              return;
                          }
          Severity: Minor
          Found in code/resources/assets/js/bookings.js - About 1 hr to fix

            Function select has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            select: function(event, ui) {
                                var aggregate_id = input.attr('data-aggregate');
                                var while_shipping = (input.closest('.modal.add-booking-while-shipping').length != 0);
                                var fill_target = input.closest('.fillable-booking-space').find('.other-booking');
                                fill_target.empty().append(utils.j().makeSpinner());
            Severity: Minor
            Found in code/resources/assets/js/bookings.js - About 1 hr to fix

              Function bookingTotal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  static bookingTotal(editor) {
                      var form = $(editor).closest('form');
                      var data = this.serializeBooking(form);
                      var url = form.attr('data-dynamic-url');
              
              
              Severity: Minor
              Found in code/resources/assets/js/bookings.js - About 55 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 deeply nested control flow statements.
              Open

                                      for (let i = product_meta.variants.length; i < total_rows.length; i++) {
                                          let varinputbox = total_rows.eq(i);
                                          varinputbox.val(0);
                                          varinputbox.closest('tr').find('.booking-product-price span').text('0.00');
                                      }
              Severity: Major
              Found in code/resources/assets/js/bookings.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (varinputbox.length == 0) {
                                            break;
                                        }
                Severity: Major
                Found in code/resources/assets/js/bookings.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          do {
                                              varinputbox = $('input[name="variant_quantity_' + product_id + '[]"]', container).filter(':not(.skip-on-submit)').eq(populated_index);
                                              if (varinputbox.length == 0) {
                                                  break;
                                              }
                  Severity: Major
                  Found in code/resources/assets/js/bookings.js - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status