Showing 133 of 5,402 total issues
Avoid deeply nested control flow statements. Open
Open
for( var j = 0; j <= promises[i].responseJSON.facilities.length; ++j) {
if( promises[i].responseJSON.facilities[j] ) {
APIresults.push(promises[i].responseJSON.facilities[j]);
}
}
Avoid deeply nested control flow statements. Open
Open
if( $('.nav-links span.current').attr('class').indexOf('faux')>-1 ) {
e.preventDefault();
if( $('.nav-links span.current').prev().attr('class').indexOf('faux') == -1 ) {
window.open($('.nav-links span.current').prev().attr('href'),'_self');
Avoid deeply nested control flow statements. Open
Open
if(programs[k].tags[l]) {
if(programs[k].tags[l].marketing_color) {
series_color += ' series-'+programs[k].tags[l].marketing_color;
}
}
Avoid deeply nested control flow statements. Open
Open
if( $(this).attr('id').indexOf( programs[k].begin_date )>-1 ) {
if (!$(this).hasClass('hasEvent')) $(this).addClass('hasEvent');
var calTarget = 'insivia-frmp-calendar-day';
listTarget = 'insivia-frmp-list-view-day';
Avoid deeply nested control flow statements. Open
Open
if (!$(this).hasClass('hasEvent')) $(this).addClass('hasEvent');
Avoid deeply nested control flow statements. Open
Open
for(var k = 0; k<=json.facilities[i].amenities.length; ++k) {
if(json.facilities[i].amenities[k]) {
results += '<li class="insivia-frmp-list-item-amenity '+slugify(json.facilities[i].amenities[k].name)+'" data-name="'+json.facilities[i].amenities[k].name+'" title="'+json.facilities[i].amenities[k].name+'"></li>';
}
Avoid deeply nested control flow statements. Open
Open
if(promises[i].responseJSON.cart.length) {
for(var j = 0; j <= promises[i].responseJSON.cart.length; ++j) {
if(promises[i].responseJSON.cart[j]) {
cartItemStart = ( promises[i].responseJSON.cart[j].start_time.split(':')[0].charAt(0) == 0 ) ? promises[i].responseJSON.cart[j].start_time.split(':')[0].slice(1)+':'+promises[i].responseJSON.cart[j].start_time.split(':')[1] : promises[i].responseJSON.cart[j].start_time.split(':')[0]+':'+promises[i].responseJSON.cart[j].start_time.split(':')[1];
Function initBlog
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function initBlog() {
function setUpBlogSorting () {
var sortList = jQuery('.blog-sorting-options');
var sortListData = sortList.attr('data-sort');
- 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
if( $('.nav-links .next').length ) {
var it = parseInt($(alreadyPaged[alreadyPaged.length-1]).text()),
b = it;
Avoid deeply nested control flow statements. Open
Open
if (count <= 3) {
$('#event-slide-' + beginDate).append(homeEvent);
$('#event-slide-' + beginDate).attr('data-event-count', count);
}
Avoid deeply nested control flow statements. Open
Open
for(var l = 0; l <= programs[k].tags.length; ++l) {
if(programs[k].tags[l]) {
if(programs[k].tags[l].marketing_color) {
series_color += ' series-'+programs[k].tags[l].marketing_color;
}
Avoid deeply nested control flow statements. Open
Open
for(var l = 0; l <= programs[k].tags.length; ++l) {
if(programs[k].tags[l]) {
if(programs[k].tags[l].marketing_color) {
series_color += ' series-'+programs[k].tags[l].marketing_color;
}
Avoid deeply nested control flow statements. Open
Open
switch(newURL[j].split('=')[0]) {
case 'park_id':
resultsForString += APIresults[0].park_name;
break;
case 'start_date':
Avoid deeply nested control flow statements. Open
Open
if(APIresults[k].amenities.length) {
for(var l = 0; l<=APIresults[k].amenities.length; ++l) {
if(APIresults[k].amenities[l]) {
console.log(APIresults[k].name +' '+ APIresults[k].amenities[l].name);
results += '<li class="insivia-frmp-list-item-amenity '+slugify(APIresults[k].amenities[l].name)+'" data-name="'+APIresults[k].amenities[l].name+'" title="'+APIresults[k].amenities[l].name+'"></li>';
Avoid deeply nested control flow statements. Open
Open
if(APIresults[k].series_id) {
$('.insivia-frmp-list-view-days').append('<li id="list-date-' + idBuild+'" class="series-'+APIresults[k].series_id+' insivia-frmp-list-view-' + cleanDay.toLowerCase() + ' insivia-frmp-list-view-day insivia-frmp-event-day active hasEvent"><span class="insivia-frmp-list-view-date"><span class="insivia-frmp-list-view-display-date">' + monthsArray[newDay.getMonth()] + ' ' + newDay.getDate() + ', ' + newDay.getFullYear() + '</span> <span class="insivia-frmp-list-view-dotw">' + cleanDay + '</span></span><ul class="insivia-frmp-list-view-event-list"></ul></li>');
}
Avoid deeply nested control flow statements. Open
Open
if(queryBuild.indexOf('type') == -1) queryBuild += '&type='+inputArray[i][0];
Avoid deeply nested control flow statements. Open
Open
if( inputArray[i][(inputArray[i].length-1)] == 'search' && source.find('input[id*='+inputArray[i][(inputArray[i].length-1)]+']').val() ) {
queryBuild = '?s='+source.find('input[id*='+inputArray[i][(inputArray[i].length-1)]+']').val();
}
Avoid deeply nested control flow statements. Open
Open
if(json.facility.rental_rates.rental_rates[j].weekday_cost == 'closed') {
popUp += '<li><span class="rental-rate">'+json.facility.rental_rates.rental_rates[j].weekday_cost+'</span></li>';
} else {
popUp += '<li><span class="rental-rate">$'+json.facility.rental_rates.rental_rates[j].weekday_cost.split('.')[0]+' weekdays</span></li>';
popUp += '<li><span class="rental-rate">$'+json.facility.rental_rates.rental_rates[j].weekend_cost.split('.')[0]+' weekends</span></li>';
Avoid deeply nested control flow statements. Open
Open
if(APIresults[k].address.address) {
results += '<p class="insivia-frmp-list-item-address-wrapper">'+
'<span class="insivia-frmp-list-item-address">'+APIresults[k].address.address+' ';
if(APIresults[k].address.address2) {
results += '<span class="insivia-frmp-list-item-address-2">'+APIresults[k].address.address2+'</span> ';
Avoid deeply nested control flow statements. Open
Open
if($('#list-date-' + idBuild).length === 0) {
if( eventDay.getDay()+1 != 7 ) {
$('.insivia-frmp-list-view-days').append('<li id="list-date-' + idBuild+'" class="insivia-frmp-list-view-' + cleanDay.toLowerCase() + ' insivia-frmp-list-view-day insivia-frmp-event-day active hasEvent"><span class="insivia-frmp-list-view-date"><span class="insivia-frmp-list-view-display-date">' + monthsArray[newDay.getMonth()] + ' ' + newDay.getDate() + ', ' + newDay.getFullYear() + '</span> <span class="insivia-frmp-list-view-dotw">' + cleanDay + '</span></span><ul class="insivia-frmp-list-view-event-list"></ul></li>');
} else {
$('.insivia-frmp-list-view-days').append('<li id="list-date-' + idBuild+'" class="insivia-frmp-list-view-' + cleanDay.toLowerCase() + ' insivia-frmp-list-view-day insivia-frmp-event-day active hasEvent"><span class="insivia-frmp-list-view-date"><span class="insivia-frmp-list-view-display-date">' + monthsArray[newDay.getMonth()] + ' ' + newDay.getDate() + ', ' + newDay.getFullYear() + '</span> <span class="insivia-frmp-list-view-dotw">' + cleanDay + '</span></span><ul class="insivia-frmp-list-view-event-list"></ul></li>');