JavaScript

JavaScript

Made by DeepSource

Found confusing labels inside switch JS-W1036

Bug risk
Major

The use of labels for control flow makes a program hard to reason about for most readers. This is especially true when they're inside a switch-statement, as they can easily be confused for case labels.

If you must use a label in a switch-case, consider adding a skipcq comment to justify the use-case. This will also prevent DeepSource from raising the issue.

Bad Practice

switch (color) {
  case RED: handle_red(color); break;
  case BLUE: handle_red(color);
  INDIGO: handle_indigo(color);
}

Recommended

switch (color) {
  case RED: handle_red(color); break;
  case BLUE: handle_red(color);
  case INDIGO: handle_indigo(color);
}