java:S131 False positive

Version : Community Edition Version 8.9 (build 43852)

Hi,

i have the following enum:

@JsonClassDescription("Possible actions to perform on slides for robotic arm")
public enum RoboticsSlideAction {
  PLACE,
  PICK,

  @JsonPropertyDescription("This means that in this position, the robotic arm must position itself in front of the position")
  NONE
}

With the following method:

private void moveToLoadLock(RoboticsSlideAction slideAction) {
    switch (slideAction) {
    case PLACE:
      ...
      break;
    case PICK:
      ...
      break;
    case NONE:
      ...
      break;
    }
  } 

All constants in the enum are used in the switch, it seems to be a false positive. It is maybe due to the fact that i use annotations in constants.

Hi ochezeau,

I tried to reproduce by adding annotations to an enum but I don’t have any false-positive.
Which message do you see?:

  1. Add a default case to this switch.
  2. Complete cases by adding the missing enum constants or add a default case to this switch.

Note: If your answer is (1) I already created this ticket SONARJAVA-3857