问题
I have around 100 non-empty cases inside a switch case. Each case calls different functions. Sonar is showing issue to reduce number of non-empty switch cases to atmost 30. Is there any alternative to implement such switch cases or there is no problem in having any number of switch cases.
for(int i=0;i<arrayList.size();i++){
switch(arrayList.get(i)){
case "A":
a();
break;
case "B":
b(10,20);
break;
...
...
case "ABZ":
abz("string1","string2");
break;
}
}
来源:https://stackoverflow.com/questions/61243218/reduce-the-number-of-non-empty-switch-cases-sonar-lint-issue