Reports switch statements or expressions that contain the same code in different branches and suggests merging the duplicate branches.

Example:


  switch (n) {
    case 1:
      System.out.println(n);
      break;
    case 2:
      System.out.println(n);
      break;
    default:
      System.out.println("default");
  }

Can be replaced with:


  switch (n) {
    case 1:
    case 2:
      System.out.println(n);
      break;
    default:
      System.out.println("default");
  }

New in 2019.1