I have a function that takes an input and does a switch case based on a specific input property. So the function itself is pretty simple, as you can see below
function handleMessage(message) {
switch (message.type) {
case "a":
a(message);
break;
case "b":
b(message);
break;
case "c":
c(message);
break;
case "d":
d(message);
break;
case "e":
e(message);
break;
}
}
But if I check the complexity for this functions I get 12, which VSCode says is too much (according to some recommendation found online the highest value for a function should be 10). As long as I add cases to the switch statement the complexity will of course increase, but the point is: is anything I can do to decrease this value? Or should I just deal with it?