-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Description
Description
(False positive, I guess? This template fits better than the new rule template.) The existing S907 goto label rule also triggers on goto case/goto default.
I have a switch statement with (currently) 26 string cases, akin to the one below. For the sake of finding the labels and reducing merge conflicts when new cases are added, the case labels are in alphabetical order. This requires either code duplication or goto case statements. It would be nice to be able to configure goto case/goto default separately from goto label.
Reproducer
switch (insectType) {
case "ant":
goto case "termite";
case "bee":
goto case "wasp";
case "termite":
// handle ants and termites
break;
case "wasp":
// handle bees and wasps
break;
}In my case, none of the case blocks with goto case contain any other code, but it might also be good to have a third setting for cases terminated with goto case, e.g.
case "bee":
// handle bee stuff that doesn't apply to wasps
goto case "wasp";
// ...
case "wasp":
// handle bees and wasps
// (everything that applies to wasps also applies to bees)
break;Product and Version
SonarQube 8.27.0.14275 and Visual Studio 17.14.16
Metadata
Metadata
Assignees
Labels
No labels