code/resources/assets/js/bookings.js
Function updateBookingQuantities
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
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));
- Read upRead up
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
Open
static init(container)
{
$('.bookingSearch', container).each((index, item) => {
var input = $(item);
File bookings.js
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import utils from "./utils";
import Modifiers from "./modifiers";
class Bookings
{
Function updateBookingQuantities
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
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));
Function bookingTotal
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static bookingTotal(editor) {
var form = $(editor).closest('form');
var data = this.serializeBooking(form);
var url = form.attr('data-dynamic-url');
Function success
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
success: (data) => {
if (data.hasOwnProperty('status') && data.status == 'error') {
utils.displayServerError(null, data);
return;
}
Function select
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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());
Function bookingTotal
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
static bookingTotal(editor) {
var form = $(editor).closest('form');
var data = this.serializeBooking(form);
var url = form.attr('data-dynamic-url');
- Read upRead up
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
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');
}
Avoid deeply nested control flow statements. Open
Open
if (varinputbox.length == 0) {
break;
}
Avoid deeply nested control flow statements. Open
Open
do {
varinputbox = $('input[name="variant_quantity_' + product_id + '[]"]', container).filter(':not(.skip-on-submit)').eq(populated_index);
if (varinputbox.length == 0) {
break;
}