I am getting 2 errors in my grunt file
line 61 col 25 This function's cyclomatic complexity is too high. (10)
line 101 col 22 This function's cyclomatic complexity is too high. (10)
how could I reduce the Cyclomatic complexity in this case ? my functions aren't that complex
first error
remove: function(line, row, type) {
var spreadSelected = (row.spreadSelected && type === 'spread'),
totalSelected = (row.totalSelected && type === 'total'),
moneyLineSelected = (row.moneyLineSelected && type === 'moneyline'),
lineValue;
if (spreadSelected || totalSelected || moneyLineSelected) {
switch (type) {
case 'spread':
lineValue = row.spread.line;
break;
case 'total':
lineValue = row.total.line;
break;
case 'moneyline':
lineValue = row.moneyLineId;
break;
default:
break;
}
AuthFactory.getCustomer().then(function(credentials) {
betSlipSelectionRequest('/betSlip/removeSelection', {
customerId: credentials.customer,
game: row.game,
pair: row.pair,
line: lineValue
});
});
if (spreadSelected) {
row.spreadSelected = false;
}
if (totalSelected) {
row.totalSelected = false;
}
if (moneyLineSelected) {
row.moneyLineSelected = false;
}
}
}...
and then the 2nd error function
add: function(line, row, type) {
var spreadSelected = (row.spreadSelected && type === 'spread'),
totalSelected = (row.totalSelected && type === 'total'),
moneyLineSelected = (row.moneyLineSelected && type === 'moneyline'),
lineValue;
if (!(spreadSelected || totalSelected || moneyLineSelected)) {
switch (type) {
case 'spread':
lineValue = row.spread.line;
break;
case 'total':
lineValue = row.total.line;
break;
case 'moneyline':
lineValue = row.moneyLineId;
break;
default:
break;
}
AuthFactory.getCustomer().then(function(credentials) {
betSlipSelectionRequest('/betSlip/addSelection', {
customerId: credentials.customer,
game: row.game,
pair: row.pair,
line: lineValue
});
});
switch (type) {
case 'spread':
row.spreadSelected = true;
break;
case 'total':
row.totalSelected = true;
break;
case 'moneyline':
row.moneyLineSelected = true;
break;
}
}
}
the weird thing here: this error is only with me, my co-worker opens the same files and run grunt and there is no errors in their terminals.