i have some problems with complexity in my javascript. It looks like:
function mainFunction(scope, element) {
var eventHandlerMap = {
'firstEvent': firstEventHandler,
'secondEvent': secondEventHandler,
.....
};
function firstEventHandler(element) {
if (element) {
//some code
} else {
//some code
}
}
function secondEventHandler(element) {
//some code
}
//and other EventHandler functions
}
Now mainFunction has complexity of 41, but my sonar allows no more than 10. I dont good at javascript and dont have ideas how fix it.